Quantcast
Channel: MobileRead Forums - Kindle Developer's Corner
Viewing all articles
Browse latest Browse all 4458

PW4 Automatic backlight when waking up

$
0
0
I want to share this small KUAL extension that briefly enables the backlight when the device wakes up.

Code:

SOURCES=$'com.lab126.powerd'

get_light_level () {
    head -n1 /sys/class/backlight/bl/actual_brightness
}

lipc-wait-event -m com.lab126.powerd outOfScreenSaver | while read event; do
    sleep 0.1
    if [ $(get_light_level) -eq 0 ]; then
        echo -n "10" > /sys/class/backlight/bl/brightness
        sleep 10
   
        if [ $(get_light_level) -eq 10 ]; then 
            echo -n "0" > /sys/class/backlight/bl/brightness
        fi
    fi
done

Background
Sometimes when reading in a bright daylight I disable the backlight to preserve some battery juice. But often, when I go to sleep and decide to read some more I then realize that BL is turned off, so I had to grab flashlight/phone/jar of fireflies to just find the controls to turn it on.
That is actually pretty annoying so here's a simple solution for that.

Solution
The script waits for device wake-up event then it checks whether the backlight is off and turns it on for 10s if it is.
During that 10s you need to adjust the BL to a desired level, as it'll go off if you don't.
Script does nothing if any level of backlight was set before.

Notes
  • Script adds a single option to KUAL menu that is used to enable/disable the script (when enabled it autostarts, so no need to reenable it after each restart).
  • Script uses lipc-wait-event interface to watch for the wake-up, and I'm still not sure whether it has any effect on the battery life.
  • There's a small bug when you quickly switch Kindle on/off many times in less than 10s, the light will stay on for 10s*number of switch on's...
  • The script should work on any Kindle with a backlight and FW 5.10+
  • If you want to adjust the time light stay's on you can do that by editing the sleep value in bin/autolight.sh.

Attached Files
File Type: zip autolight_1.0.zip (1.9 KB)

Viewing all articles
Browse latest Browse all 4458

Trending Articles