View Single Post
Old 01-02-2013, 02:29 PM   #63
DuckieTigger
Wizard
DuckieTigger ought to be getting tired of karma fortunes by now.DuckieTigger ought to be getting tired of karma fortunes by now.DuckieTigger ought to be getting tired of karma fortunes by now.DuckieTigger ought to be getting tired of karma fortunes by now.DuckieTigger ought to be getting tired of karma fortunes by now.DuckieTigger ought to be getting tired of karma fortunes by now.DuckieTigger ought to be getting tired of karma fortunes by now.DuckieTigger ought to be getting tired of karma fortunes by now.DuckieTigger ought to be getting tired of karma fortunes by now.DuckieTigger ought to be getting tired of karma fortunes by now.DuckieTigger ought to be getting tired of karma fortunes by now.
 
DuckieTigger's Avatar
 
Posts: 4,742
Karma: 246906703
Join Date: Dec 2011
Location: USA
Device: Oasis 3, Oasis 2, PW3, PW1, KT
DIY turn of the light

For now I will simply post it as DIY instructions. Not sure when and if I get around to get it packaged (never packaged anything, so my learning curve starts at ZERO).

You need USB Network access to your Paperwhite. I do not wish that anyone just follow these instructions unless they are comfortable doing it. If you scratch your head, because something doesn't make sense, then DON'T DO ANY OF THIS. Please don't complain later that I did not warn you.

Instructions are in the Spoiler:
Spoiler:

The Hack, as you can see, is rather simple and short. That doesn't mean it is not doing what it should. It also means that it is less likely to misfunction. What does it do? When you wake up from sleep (either by pushing the power button or by opening your cover) the light of the Paperwhite gets turned of. This happens if and only if these conditions are met:
- the file TURN_LIGHT_OFF exists in folder /mnt/us (empty or not doesn't matter)
- the light is set to level 0 (no bars showing) according the setting screen of the Paperwhite

Also make sure that lipcd is running and using the correct settings. Easiest way to make sure is to stop it (stop libcd) and restarting it (start lipcd) after you made the change to the config file. Once it is running, it doesn't need to be restarted again. No need to go back into the USB Network for it to keep working after eventual restarts.

Now to install it you need to:
STEP 1)
Create the file /usr/bin/lightoff.sh with the following content. When I made did it I copied another shell script to the new file and replaced the content. (That was easier for me than to figure out what permissions the Kindle likes to have)
Code:
#!/bin/sh
#
FLINTENSITY=`lipc-get-prop com.lab126.powerd flIntensity`
if [ -e "/mnt/us/TURN_LIGHT_OFF" ]
then
        if [ "$FLINTENSITY" -eq 0 ]
        then
                sleep 1;
                /bin/echo -n 0 > /sys/devices/system/fl_tps6116x/fl_tps6116x0/fl_intensity;
        fi
fi
Here is also the chance to modify it to a desired (other than 0) intensity setting, if you so wish. Please note that the intensity I check against is the setting of the bar, not the actual setting the light is set on (so it should be 0-24). Who knows what logic Amazon uses to translate light bars into real intensity values - plus it might change. I gave my reasons before on why I won't change it to anything else than 0 or to make it customizable. Not going to repeat myself. That I coincidentally made it so easy to customize has nothing to do with my foresight of it beeing a possibility. In fact, if it would have created cleaner code, I would have avoided this. You might also notice the lack of comments in the script. That is on purpose as well, it practically reads itself. If it doesn't for you, then don't mess with it. A little side note for the the necessity of the delay in there: If you take the call to sleep out, the whole functionality will break. I believe it has something to do with calling and finish executing the script BEFORE the Kindle had time to turn the light on. If the light is not on, then turning it off is redundant. Even worse, the light would stay on, contrary to what you want to do. (Doh )

Step 2)
The file /etc/lipc-daemon-events.conf needs the last line added (in green). This is the complete file, the non-green part is the default file. It even includes (and I did not edit that) the typo evetns (in red) .
Code:
## This file defines what evetns are handled by lipc-daemon
## The format of the file is
##<event name>   <event publisher>   <command to execute when event is received>
##
## NOTE: By default the event name and any parameters are passed to the script as arguments.  If you want to ignore the arguments,
## you must add a semi-colon (;) to the end of the script command.
##
FrameworkStarted  com.lab126.framework  rm -f /var/local/system/.framework_retries /var/local/system/.framework_reboots
tzRequested       com.lab126.framework  settz
interfaceChange   com.lab126.cmd        /usr/sbin/updatetime;
triggerTimeChange com.lab126.cmd        /usr/sbin/updatetime
networkTime       com.lab126.wifid      /usr/sbin/setdate

## Uncomment the following line if you want to see when lipc-daemon received
## outOfScreenSaver event.  Useful for debugging out of suspend performance
#outOfScreenSaver    com.lab126.powerd  . /etc/rc.d/functions; msg "lipc-daemon got outOfScreenSaver at `date +%s`s" I; true;
outOfScreenSaver com.lab126.powerd  /usr/bin/lightoff.sh
Please note: If you ever want to edit this file again and try out to uncomment the other outOfScreenSaver, then you MUST comment out the one for the light. If you have 2 lines with the same event, it does not call any of them. Also, you NEED to restart the lipc daemon after you edited the file. (see above)

last not least:
Step 3)

The file TURN_LIGHT_OFF needs to be in usb partition (/mnt/us) (so that it can be disabled simply by deleting or renaming the file - just like USE_ALT_FONTS). That is an easy way to turn the light hack completely on or off with only access to the usb-visible disk.

Simplest way to make it is like this:
Code:
/bin/touch /mnt/us/TURN_LIGHT_OFF


I hope this is useful. If I get enough time this weeking, I will try to start figuring out on how to package it. It all but looks like a short weekend aka nonexistant. Shutdown over Christmas / New Year usually comes to haunt us with a vengence in the form of overtime. Tonight it is time for me to go back to work .

p.s.: If someone wants to have a go at packaging it, please feel free to do so and use all knowledge and code. If you change functionality (e.g. different light level, customizable light level or anything) please don't claim that it was my work. The code I made is robust, but I won't voucher for it if it is changed. And yes if you want to give me credit for inspiration, feel free to do so. If it wasn't for others, even this would not have been possible. Special thanks to: knc1 and twobob (they know why)

p.p.s: Just seen ixtab has the margins fixed in JBPatch (see here). Yay good timing on his part. Time to tinker with that a bit.

Update: decided to lay the packaging on ice for now. This is really easy enough to do if you have usb network installed. Plus since I discovered a way to turn the light off w/o jailbreak, there is no incentive for me right now to learn a new trick. See post #78 for the joilbreak free method.

Last edited by DuckieTigger; 01-07-2013 at 02:27 AM. Reason: updated
DuckieTigger is offline   Reply With Quote