[Nexus S Android Development] Ezekeel:
**** OUTDATED !!!! SEE BELOW ****

Version 1.0

It bugged me that there was no way to switch off the touchkey backlights on the Nexus S, so I looked into it. Starting with the Netarchy kernel I made some modifications exposing two switches in /sys/.../backlightnotification/ to manually turn on/off the button backlights. However on my i9020 the button backlights get activated automatically once you use the touchkeys - I could not check the i9023 since I do not have one. This behaviour seems to be controlled by the touchkey firmware which only is available as a binary, so without some hex editing the binary there seems to be no way to change this. The next best thing would be to disable the touchkey backlights everytime they get activated, however since I am lazy instead I chose a quick and dirty approach of using a cron daemon to simply trigger the off-switch once every minute. This is good enough so the backlight does not bother me while watching movies, etc. and the extra battery drain is practically zero.

Downloads:

www.multiupload.com/CHFDDBV6BP Kernel for 2.3.3 Custom ROMs

www.multiupload.com/0RPO16QCN0 Kernel for 2.3.4 Custom ROMs

www.multiupload.com/823MR3UZVD Kernel for 2.3.4 Stock ROM (unlock and root required)

www.multiupload.com/WYBGK5N3H9 Cron Backlight Dimmer for all ROMs (root and busybox with crond* required)

www.multiupload.com/EXC6465ZRC Cron Backlight Dimmer for all ROMs including busybox 1.18.4 (root required)

* How to check if your busybox supports crond:

Either in terminal app or adb shell write 'busybox --list | grep crond'. If you get 'crond' as a response your version of busybox supports crond.

Changes to the source code:

www.pastie.org/2122063

**** ALSO OUTDATED !!!! SEE BELOW ****

Version 2.0

Based on the latest BLN version 9, I made some modifications to implement a backlight dimmer which does not need an external program (like cron) to trigger an off-switch.

To activate the dimmer, just echo the dim interval in ms (this is milliseconds; 1000ms = 1s) into /sys/class/misc/backlightnotification/in_kernel_dimmer. If you pass a value of 0, the dimmer will be deactivated.

Here are the modifications to the source code: http://www.pastie.org/2378721

**** UPDATE ****

Version 3.0

Another day, another backlight dimmer version. :)

The previous implementations had the drawback that the time when the touchkey backlights were switched off was entirely independent of the time the touchkeys were pressed (and thus reactivated) for the last time. Consequently, the time until the backlights were deactivated was essentially random and could vary from practically zero up to the defined interval value.

Some people commented on that and I agree that it would simply look much more elegant if the dimmer would behave more consistently. So I sifted through the source code and found a way to detect the a press of the touchkeys which both works for the i9020 and i9023. This made it possible to link the dimming of the touchkey backlights to a touchkey press and have the backlights switched off with a consistent delay.

Also, this time instead of being lazy and simply hacking the dimmer functionality into BLN, this implementation does not depend on BLN anymore and can be included in the kernel independently of BLN (with CONFIG_BLD=y). This should improve the maintainability in case BLN or this tweak gets updated.

In /sys/class/misc/backlightdimmer, pass 1 or 0 to 'enabled' to enable or disable the dimmer. Pass the delay in ms (this is milliseconds; 1000ms = 1s) to 'delay'. The default state is disabled and a delay of 5000 = 5s.

Changes to the source code:

http://www.pastie.org/2388552

http://www.pastie.org/2388562

http://www.pastie.org/2388614

BUGFIX

I got reports about the delay not properly working. Found a bug that might have caused this problem.

Bug fix: http://www.pastie.org/2392734

BUGFIX #2

Turns out the implementation of the Backlight Dimmer was potentially unstable. I have made some changes to avoid possible problems.

Bug fix: http://www.pastie.org/2403815

BUGFIX #3

BLD was not working properly for the i9023 since the backlights were not re-enabled on touch which has been fixed in this patch.

Bug fix: http://www.pastie.org/2419575

BUGFIX #4

Patch to avoid race conditions.

Bug fix: http://www.pastie.org/2441553

No further patches will be published here. I have set up a git repo for all my tweaks. Each mod has its own branch to keep the tweaks cleanly separated and one can simply pull the latest patches from the corresponding branch.

https://github.com/Ezekeel/GLaDOS-nexus-s/tree/bld

Get Jonathon Grigg's 'Spark Mod Manager' GUI for controlling BLD: http://xdaforums.com/showthread.php?p=17291034

Thanks to Netarchy for his help.

I do not accept donations and since I reached my 50GB limit of free space on SpiderOak, thanks to all of you kind people who got an account using my referral link, I could not ask for more.

Instead if you really want to donate your hard earned money to someone who deserves and needs it, consider donating to the Free Software Foundation at fsf.org: These guys are at the frontline when it comes to keeping Linux free and fighting these greedy bastards who think they are entitled to collect royalties and other fees from Linux users due to some silly patents - and if Linux falls, Android will be next.