description "Select thermal limits"
author "Semi Malinen"

start on started dbus

console output

script
        THERMALCONFIG=/etc/dsme/temp_surface
        THERMALTOOL=/usr/bin/dbus-send
        THERMALARGS="--system \
                     --print-reply \
                     --dest=com.nokia.SystemInfo \
                     /com/nokia/SystemInfo \
                     com.nokia.SystemInfo.GetConfigValue \
                     string:/certs/ccc/pp/thermal-manager-raw"
        THERMALPATTERN="byte 2"

# sleep is not required, since sysinfod is service now and starting up per request if not started yet
#        sleep 3

        rm -f $THERMALCONFIG
        if [ -x $THERMALTOOL ] ; then
            if THERMALBITS=$($THERMALTOOL $THERMALARGS) 2> /dev/null ; then
                if echo $THERMALBITS | grep -q "$THERMALPATTERN" ; then
                    cat > $THERMALCONFIG <<-'EOF'
			-99, 110, 5
			110, 115, 5
			115, 120, 2
			120, 999, 2
			EOF
                    /usr/sbin/dsmetool -a
                    echo "Using wide thermal limits"
                else
                    echo "Using normal thermal limits"
                fi
            else
                echo "No thermal bits; using normal limits"
            fi
        else
            echo "No thermal tool; using normal limits"
        fi
end script
