[MOD] Script to toggle the keylights

mmarz

Well-known member
Mar 9, 2011
1,130
447
0
Visit site
I had been using an app called keylights to flash the black-light on my hardware keys when I had missed calls or texts. More info about that app here: KeyLights 0.2 - Capacitive Lights As Notification - Updated June 3, 2010. Here is a modified version I made with more options: KeylightsOV_signed.apk
Unfortunately, that app refuses to install on some of the roms. Also, the app would only notify you of texts but not missed calls, missed voip calls, GV messages, Gtalk messages...etc.

So I did some digging and figured out how to toggle the backlight myself. The attached script will turn the lights on for a split second second and then turn them off. If you open the script, you'll see that there really is nothing hard about implementing this. Combine this with Tasker and disabling the lights when you press the hardware keys, and you have yourself a dedicated notification light.

Here is how to set this up to work on your phone with Tasker:

  1. Install tasker
  2. Install sl4a
  3. Download the Keylights.rar and extract it.
  4. Place userbackup.xml in /sdcard/tasker
  5. Place sush into /system/bin and change the permissions to "rwxr-xr-x"
    Code:
    adb remount
    adb push sush /system/bin/
    adb shell chmod 755 /system/bin/sush
  6. Place the four script files into /sdcard/sl4a/scripts
  7. Open tasker, hit the menu, profile data, restore
  8. Press apply to exit Tasker, and Go to Settings>Accessibility> Enable Accessibility for Tasker
  9. Reboot!

As is, this will flash the button backlight LED's if you get a missed call, text, GV message, Gtalk message, or Groove IP missed call. If you want other notifications to trigger the lights, in Tasker hit New -> Event -> UI -> Notification -> Owner Application -> and select the app who's notifications you want to trigger the lights. When the Task Selection Menu pops up, select Togglekeylights.

If you want to change the interval of flashing, edit the task of the Keylights profile. Change all the wait values. That profile is setup in that way to minimize the number of loops Tasker has to do.

This mod stops the blacklight from turning on when you press the key. If you just want to do the same on your own without Tasker, run the following through adb shell or a script with root privileges:
Code:
chmod 0333 /sys/class/leds/button-backlight/brightness
echo 0 > /sys/class/leds/button-backlight/brightness
To reverse it:
Code:
chmod 0647 /sys/class/leds/button-backlight/brightness
or just reboot. You'll need to run the disable command after every boot if you want the backlight to not turn on with a press of the keys. With the backlight disabled, you will still be able to flash it using the script provided. You are merely locking out the system from turning on the backlight. To implement this using tasker, delete all of the Tasker profiles except "Boot".

If you do want your key backlight to function when you press the keys with this mod, delete the "Boot" profile, and reboot your phone.

Also, I did this:
http://forum.androidcentral.com/opt...ng-external-notification-light-optimus-v.html
I think I voided my warranty :D

With the flashing led script, disabling the led with key presses, and finally adding an external spot for the led, you'll have a fully functional and dedicated notification led.

Bonus:
After downloading the Keylights rar, replace the keylights.sh script with one of these for different flashing goodness. The built in keylights.sh is a single quick flash.
Single slow flash
Double quick flash
Double slow flash
Triple quick flash
Special flash
Flashdance

You could even create different flashing types for different notifications but it is up to you to figure that out.
 
Last edited:

Takenover83

Well-known member
Mar 7, 2011
499
76
0
Visit site
Nice. I know I will giving this a shot mmarz. Thanks for the script and instructions.

Edit: Any chance of you sharing your tasker profile data? (Menu>Profile Data>Backup). I am still learning the ropes, reading over the wiki.
 
Last edited:

mmarz

Well-known member
Mar 9, 2011
1,130
447
0
Visit site
Here you go. You get my other profiles as a bonus. The ones that are necessary are:
Screen-on
Keylights
Missed Text, GV, Call, VOIP, GT


I hand edited the google talk profile to detect google talk notifications, so you may not want to change the trigger on that one.

Also, you'll need sl4a to run the scripts for you. After you install it, put the two script files in the /sdcard/sl4a/scripts folder. The reason there are two scripts is that one toggle's the lights while the other one runs the toggle lights script as root since sl4a can't do it natively. And in order to make that little trickery work, you need to place the sush binary, that is also included, into your /system/bin folder and set the permissions to "rwxr-xr-x". In Tasker you select the script key-flash.sh, and that runs keylights.sh as root. Annoying but necessary.
 
Last edited:

mmarz

Well-known member
Mar 9, 2011
1,130
447
0
Visit site
Is there a way to disable the button lights all together?

Sent from my VM670 using Tapatalk

That would require a change at the rom/kernel level. When the buttons are pressed, that sends a notification to turn on the light. You need to disable that notification somehow.

This feature itself would be a great addition to a rom, I think. It would require a lot of work, but if one of the rom devs were to take it on, I would have no choice but to use their rom exclusively and to curse all the other roms.

Update: I was wrong. There is a way to disable them. Check the main post to see how.
 
Last edited:

anon(182107)

Well-known member
Feb 20, 2011
235
29
0
Visit site
Maybe somethings wrong with my backlight. My button lights are almost never visable. Is it normal for the button lights to be very dim?

Sent from my Optimus V using Tapatalk
 

mmarz

Well-known member
Mar 9, 2011
1,130
447
0
Visit site
In strong light, it is hard to see them. At night, they are clearly visible. I've considered opening up the phone and replacing the led with a brighter one...but that requires more time than I have.
 

vee

Well-known member
Feb 17, 2011
283
14
0
Visit site
That would require a change at the rom/kernel level. When the buttons are pressed, that sends a notification to turn on the light. You need to disable that notification somehow.

This feature itself would be a great addition to a rom, I think. It would require a lot of work, but if one of the rom devs were to take it on, I would have no choice but to use their rom exclusively and to curse all the other roms.

Yep same here. Can't tell you how many times I wait the 5 seconds for the lights to turn off to continue using the page. Bit OCDish.

Gj on script btw

Sent from my VM670 using Tapatalk
 

Takenover83

Well-known member
Mar 7, 2011
499
76
0
Visit site
Tested the script. It works fine. I copied it to "/system/bin" as I knew that was in my path. I also made sure it was executable. Now I just need to get it working in tasker.

Any other Tasker options I should be mindful of? Your GV Tasker profile, is that for Google Voice SMS?
 

mmarz

Well-known member
Mar 9, 2011
1,130
447
0
Visit site
Tested the script. It works fine. I copied it to "/system/bin" as I knew that was in my path. I also made sure it was executable. Now I just need to get it working in tasker.

Any other Tasker options I should be mindful of? Your GV Tasker profile, is that for Google Voice SMS?

Yes it is for Google Voice SMS.

I wish there were more options but Tasker is the only kid on the block that can do all the tasks we want. You'd need to develop your own app otherwise.
 

mmarz

Well-known member
Mar 9, 2011
1,130
447
0
Visit site
You place the scripts in this folder: /sdcard/sl4a/scripts/

Then when you are in tasker selecting the script, you press the search button all the scripts in that folder pop up as options.

Have you installed sl4a yet?
 

mmarz

Well-known member
Mar 9, 2011
1,130
447
0
Visit site
Also, I had some free time on my lunch break, so I did this:

125hxkz.jpg


Details and a step by step to come later, but I did this the old school MacGyver way. All you need is an eyeglass repair kit, a drill, and some tape. :D
 

Takenover83

Well-known member
Mar 7, 2011
499
76
0
Visit site
I had not. Just googled it and installed. The only thing I have done is the following

Install tasker
Load your backup for tasker
install sl4a
Put scripts in the correct folder (sdcard/sl4a/scripts/)
chmod them (not sure if I had to that)

I have been sending test messages to my google voice. I am still trying to get my mind around tasker. It's very in-depth/daunting...

Edit: Nice mod.I wonder if you could get it to the right of the Virgin Mobile logo?
 

mmarz

Well-known member
Mar 9, 2011
1,130
447
0
Visit site
Edit: Nice mod.I wonder if you could get it to the right of the Virgin Mobile logo?

You can, there are three LED' that make up the back light for the keys. They are located in between the keys. I picked that one because it was the easiest to do, but you could do one in the center or on the right.
 

vee

Well-known member
Feb 17, 2011
283
14
0
Visit site
Also, I had some free time on my lunch break, so I did this:

125hxkz.jpg


Details and a step by step to come later, but I did this the old school MacGyver way. All you need is an eyeglass repair kit, a drill, and some tape. :D

Bet you could sell this mod on Craigslist.

Sent from my VM670 using Tapatalk
 

mmarz

Well-known member
Mar 9, 2011
1,130
447
0
Visit site
Bet you could sell this mod on Craigslist.

Sent from my VM670 using Tapatalk

But where is the fun in that? It would also not be worth my time. After I put out the directions, almost anyone will be able to do it with minimal effort. I don't understand why LG didn't think this was necessary.
 

Takenover83

Well-known member
Mar 7, 2011
499
76
0
Visit site
Notification light would of been nice. Armv7 cpu or above would of been better. So many cools games/apps I can not purchase because they are armv7. But I am getting off topic.

Edit #1: Do we need screen-on.sh and screen-off.sh?
Edit #2: Just re-read post #3. Did not place the binary...
Edit #3: I got it work, yay! Placed the binary, chmod'ed it, opened sl4a and ran the script once to grant sl4a superuser permissions.
Edit #4: Keeps flashing unless I enable screen-on & screen-off. But if those are enabled, I get a error saying those do not exist, as they were not included. But the flashing does stop.
 
Last edited:

mmarz

Well-known member
Mar 9, 2011
1,130
447
0
Visit site
Notification light would of been nice. Armv7 cpu or above would of been better. So many cools games/apps I can not purchase because they are armv7. But I am getting off topic.

Edit #1: Do we need screen-on.sh and screen-off.sh?
Edit #2: Just re-read post #3. Did not place the binary...
Edit #3: I got it work, yay! Placed the binary, chmod'ed it, opened sl4a and ran the script once to grant sl4a superuser permissions.
Edit #4: Keeps flashing unless I enable screen-on & screen-off. But if those are enabled, I get a error saying those do not exist, as they were not included. But the flashing does stop.

I exported all of my Tasker profiles. That included portions that had nothing to do with the notification hack. You don't need the screen off profile or the boot profile. For the screen on profile, you can edit the task and remove the part that runs screen-on.sh. That is my firewall profile.

Here is how the setup works.

Flashing lights:
The Keylights profile is waiting for the variable "KEYLIGHTS" to be set to "Go". When that happens, it will run the keylights script and then set the variable "KEYLIGHTS" to "Go2". Because the variable has changed, the Keylights profile will end. That cases the exit task to be performed. The exit task waits 10 seconds, and then sets "KEYLIGHTS" to "Go" again. This causes the Keylights profile to be triggered again. And this loops forever unless interrupted. (you can edit the 10 seconds to any value you want)

Triggering the flashing lights:
Then we setup profiles for different types of notifications. We'll use the SMS one as an example. When you get an SMS, the profile is activated and that causes the variable "KEYLIGHTS" to be set to "Go". That act causes the Keylights profile to be activated since it is waiting for "KEYLIGHTS" to be set to "Go".

Ending the flashing lights:
The last profile is the screen-on profile. This is triggered whenever you turn on the screen. When that happens, the task will set "KEYLIGHTS" to "Off". Since "KEYLIGHTS" is set to off, the Keylights profile will no longer work, and so if it is looping to flash the lights, it will stop.


And to make all of this work correctly, I've added some "if" conditions. Like the script will only flash if the screen is already off. The triggers also only work if the screen is off.
 
  • Like
Reactions: asadullah

Forum statistics

Threads
943,144
Messages
6,917,506
Members
3,158,841
Latest member
kirk781