[Q] Controlling key backlight LEDs - Epic 4G General

Has anyone figured out how to control the backlight on the Home, Menu, etc soft buttons on a rooted Epic?
I am looking in /sys/class/leds/ and there are five directories:
blue/
red/
mmc0::/
mmc1::/
mmc2::/
By changing the content of the brightness file in blue/ and red/ I am able to turn the blue and red notification LEDs on and off; but the mmc* directories don't seem to do anything, and I can't figure out how to control the softkey LEDs.
Code:
# cd /sys/class/leds/mmc0\:\:/
# cat brightness
0
# echo 255 > brightness
# cat brightness
0
# cat /sys/class/leds/device/leds/mmc0\:\:/brightness
1
# echo 0 > /sys/class/leds/device/leds/mmc0\:\:/brightness
# cat /sys/class/leds/device/leds/mmc0\:\:/brightness
1
What I primarily want to do is get those softkey lights to turn off and stay off while I am reading an ebook. This was easy on my Samsung Moment:
Code:
echo 0 > /sys/class/leds/button-backlight/brightness
Any clues?

I have been wanting this since the beginning. The softkey leds seem to be connected to the keyboard backlight. Even if I could just turn off the keyboard backlight entirely (i.e. changing the timeout does not help ebook reading), I would be happy.

Just set it to 3secs then it would turn off fast works for me when reading ebook.
Sent from my SPH-D700 using Tapatalk

Hmmm. The choice between a bright light shining in my face or a bright light flashing in my face? Neither are acceptable.

in fact, i hope it could be on when screen is on, although there is an option "Same as screen timeout", it simple set the timeout the same as screen's, i mean, they just do not sync. when you opened some app keep the screen on, the keys will fade a few moment later, no matter what you've set, that's really frustrating me!

I've been searching for the control file and found this. It looks promising, but its zero length. I was expecting it to contain a value like the blue & red ones.
Code:
/sys/devices/platform/s3c-keypad/brightness

After forgetting about this for a long while, I found it!
/sys/devices/virtual/misc/melfas_touchkey/brightness is the file that controls the softkey backlight on the Epic.
Use
Code:
echo 0 > /sys/devices/virtual/misc/melfas_touchkey/brightness
to turn off the backlight.
Code:
echo 1 > /sys/devices/virtual/misc/melfas_touchkey/brightness
to turn on the backlight.
Code:
chmod 0333 /sys/devices/virtual/misc/melfas_touchkey/brightness
to prevent other apps from changing the backlight's on/off status. And
Code:
chmod 0647 /sys/devices/virtual/misc/melfas_touchkey/brightness
to undo the previous line's lockdown.

Please post questions in General section.

Try out SimpleLEDToggle Plus in the Market. It's 99 cents. It didn't work for me but that's probably because I'm not rooted. There was a comment that it worked on the Epic. It specifically said that you can use it for reading ebooks with the lights off.
Sent from my SPH-D700 using XDA App

dennistpm said:
Try out SimpleLEDToggle Plus in the Market. It's 99 cents. It didn't work for me but that's probably because I'm not rooted. There was a comment that it worked on the Epic. It specifically said that you can use it for reading ebooks with the lights off.
Sent from my SPH-D700 using XDA App
Click to expand...
Click to collapse
Big plus if this works...I will check it out.

SimpleLedtoggleplus doesn't work. I lost my buck but I contacted the dev and told him about this thread. 15 minutes it too short. It should be 60 at least

This line does not work under 2.2 rooted,
Code:
echo 0 > /sys/devices/virtual/misc/melfas_touchkey/brightness
The updated line is
Code:
echo 2 > /sys/devices/virtual/misc/melfas_touchkey/brightness
Works for me, your mileage may vary.
The suggested chmod seems to have no impact, for me, nor does 0444 or 0000.
Now to find a way to tie a desktop icon to a shell script... (sure it's easy for you, but I'm a n00b)
Chisight

a way to tie a desktop icon to a shell script

ZenInsight said:
SimpleLedtoggleplus doesn't work. I lost my buck but I contacted the dev and told him about this thread. 15 minutes it too short. It should be 60 at least
Click to expand...
Click to collapse
Thing is, with android and linux being so free in regards with what you can do, 15 minutes is just under enough time to download the app, install, back up the app data, transfer it to your pc, then request a refund.
Sent from my Epic 4G via Tapatalk

It wouldn't take 15 mins to do that...
Sent from my Nexus S using XDA App

chisight said:
This line does not work under 2.2 rooted,
Code:
echo 0 > /sys/devices/virtual/misc/melfas_touchkey/brightness
The updated line is
Code:
echo 2 > /sys/devices/virtual/misc/melfas_touchkey/brightness
Works for me, your mileage may vary.
The suggested chmod seems to have no impact, for me, nor does 0444 or 0000.
Now to find a way to tie a desktop icon to a shell script... (sure it's easy for you, but I'm a n00b)
Chisight
Click to expand...
Click to collapse
Wow!!! Did you actually get the hard key lights to shut off???!

I've been wanting this for about a year now and finally found a solution.
I odin'd EF02Plus rom (gingerbread) yesterday and last night while reading I noticed that the button leds now do not come on when I touch the screen (YES!!!). The leds do come on just fine if you tap a hardware button. Perfect setup for night reading.
Not sure if this is the same in all EF02 based roms or not, but I'm guessing it probably is.

retrobits said:
I've been wanting this for about a year now and finally found a solution.
I odin'd EF02Plus rom (gingerbread) yesterday and last night while reading I noticed that the button leds now do not come on when I touch the screen (YES!!!). The leds do come on just fine if you tap a hardware button. Perfect setup for night reading.
Not sure if this is the same in all EF02 based roms or not, but I'm guessing it probably is.
Click to expand...
Click to collapse
You are kidding? That's it? I wonder if it's the rom or kernel.

Hey guys,
Not sure if this is still useful to anybody. I'm on EH 17 CM7.1 Kang and I found the values for controlling the brightness of the softkeys and the hardkeys
For the face soft keys (better reading ebooks):
Code:
/sys/devices/virtual/sec/t_key # echo 0 > brightness
For the keyboard keys (to save power either typing or playing emulated games):
Code:
/sys/devices/platform/s3c-keypad # echo 2 > brightness
Hope this helps.

thephawx said:
Hey guys,
Not sure if this is still useful to anybody. I'm on EH 17 CM7.1 Kang and I found the values for controlling the brightness of the softkeys and the hardkeys
For the face soft keys (better reading ebooks):
Code:
/sys/devices/virtual/sec/t_key # echo 0 > brightness
For the keyboard keys (to save power either typing or playing emulated games):
Code:
/sys/devices/platform/s3c-keypad # echo 2 > brightness
Hope this helps.
Click to expand...
Click to collapse
Very cool! Disabling soft key backlight does turn them off and stop them from lighting on screen press in cm7, but pressing a softkey lights them up again. I hope this info can help the screen filter app dev on our epics!

Related

Softeky lights on - off trackball on - off

Here is a couple of scripts of everyone, this will make your roms ANYROM for the eris turn on or off your trackball lights, and or softkey lights
I noticed a few roms that have problems with lights so I figured I would put these here to fix this problem.
If you just want to be able to turn on or off your softkey lights or trackball just download the script and put then in /sdcard/gscript
now download gscript app from the market and load a script file from sdcard
save the script and run threw gscript.
http://www.multiupload.com/1EWEV8MK48
If your a rom developer you can easily make these changes to the init.post-boot.sh and have the settings started at boot just add what ever script you want to init.post-boot.sh like this
open init.post-boot.sh add to file at the very top second line
Code:
# Initialize lights at boot to enable softkey lights noti$
echo 1 > sys/class/leds/vtkey-backlight/brightness
sleep 1
save and reboot.
So, to be clear, these scripts switch on or off the softkey lights and only switch on the trackball light, right? They do not enable or turn on the ability of the ROM to control these, right? For that you would have to incorporate some system components (or a 3rd-party app like Light Flow, which seems to be able to do the same thing). I'm not trying to give a hard time, just trying to understand how this works. I've tried doing similar things on evervolv and GST with no luck.
Oh, and one other thing, in your readme you mention
Notice, if you make trackball on run at boot your phone will lag, and after a while reboot this is a known issue to do with memory loss. Just run from gscript and you will be ok, it doesnt do anything to memory, just uses up all the ram/buffer so your phone reboots. if run at startup if it is just run through gscript everything will work fine.
Click to expand...
Click to collapse
What is the "known issue to do with memory loss?" I'm working on a navigation-related reboot problem at the moment and wondering about the ROM using up the RAM/buffer and if it is related. Mil gracias!
klobkelosh said:
So, to be clear, these scripts switch on or off the softkey lights and only switch on the trackball light, right? They do not enable or turn on the ability of the ROM to control these, right? For that you would have to incorporate some system components (or a 3rd-party app like Light Flow, which seems to be able to do the same thing). I'm not trying to give a hard time, just trying to understand how this works. I've tried doing similar things on evervolv and GST with no luck.
Click to expand...
Click to collapse
the lights on works but need to find out how to make them go off,, i add them to the rom but lights jjust stay on even with the phone sleeping , i sent a pm just waitin on a answer
Ok, you can use Light Flow from the market to control the lights but yes, this is only to enable and disable the light. for some reason roms are haveing a problem turning on the lights there just doesnt seem to be any one or off switch. I also have found that in alot of the roms a few that i have flashed that have been ported from the hero are missing a few of these lines
chown system system /sys/class/leds/vtkey-backlight/brightness
chown system system /sys/class/leds/amber/brightness
chown system system /sys/class/leds/jogball-backlight/brightness
chown system system /sys/class/leds/green/brightness
Click to expand...
Click to collapse
and few others like trigger,uevent if you want the full list ill pm it
androidifyme said:
Ok, you can use Light Flow from the market to control the lights but yes, this is only to enable and disable the light. for some reason roms are haveing a problem turning on the lights there just doesnt seem to be any one or off switch. I also have found that in alot of the roms a few that i have flashed that have been ported from the hero are missing a few of these lines
and few others like trigger,uevent if you want the full list ill pm it
Click to expand...
Click to collapse
im looking in my boot img and i see all those lines u mentioned
pming.....
ok ,, and btw i linked them to ur thread in the op

Disabling authors screensaver

Is it possible to completely disable the automatic activation of the screensaver? I don't see it in settings, the longest interval for this to happen is 1 hour, but no option to disable it completely. I already installed the No Lock app, but this only helped me to get rid of the slide to unlock screen. Thank you for any ideas.
Martin
Martin2603 said:
Is it possible to completely disable the automatic activation of the screensaver? I don't see it in settings, the longest interval for this to happen is 1 hour, but no option to disable it completely. I already installed the No Lock app, but this only helped me to get rid of the slide to unlock screen. Thank you for any ideas.
Martin
Click to expand...
Click to collapse
All settings are here:
http://developer.android.com/reference/android/provider/Settings.System.html
In you case you'll need:
adb shell
sqlite3 /data/data/com.android.providers.settings/databases/settings.db
-- check current value
select * from system where name='screen_off_timeout';
120000 - 2 min
3600000 - 1 hour
2147483647 = 596.5 hours
-- set
update system set value='2147483647' where name='screen_off_timeout';
.q
^d
or you can pull/mod/push alternatively.
Won't disabling the screensaver keep the screen and IR sensors active, thus eating up battery life significantly when not in use?
I know some folks would like to get rid of the swipe, waking up on a screen tap (mostly for accessibility issues), but I think some sort of screen (actually, battery) saver is still important.
Great link, ApokrifX. Would you happen to know if WIFI_SLEEP_POLICY does anything on the NST? I use Tasker to shut wifi off when the screen goes off, but I wonder if that might be easier?
bobstro said:
Great link, ApokrifX. Would you happen to know if WIFI_SLEEP_POLICY does anything on the NST? I use Tasker to shut wifi off when the screen goes off, but I wonder if that might be easier?
Click to expand...
Click to collapse
No idea.
I bet, it won't work...
Try and let us know?
ApokrifX said:
No idea.
I bet, it won't work...
Try and let us know?
Click to expand...
Click to collapse
I need to find a program that will let me know when wifi is on or off relative to the screen. On other devices, I can see that info in the battery status, but I'm not finding a similar option for the NST.
I *did* find a little program that would toggle it, but the NST lasts so long on battery, it's hard to tell if it's making any difference.
Actually, to disable the screensaver completely:
Code:
update system set value=-1 where name='screen_off_timeout';
I haven't found a way to disable the keyguard yet, but if you have one of the side keys set as Menu that dismisses the keyguard.
Renate NST said:
Actually, to disable the screensaver completely:
Code:
update system set value=-1 where name='screen_off_timeout';
Click to expand...
Click to collapse
Hi Renate again ( you adviced me with manual time set in NST
http://forum.xda-developers.com/showthread.php?p=30560605#post30560605, thanks).
I like the tweak (to disable the screensaver completely) also. But not understanding how to do this in internal terminal. Not shell and not busybox know the sqlite3 app and update command?
I fixed it so:
you must install SQLite3 to the NST you can just push it to the device. [unzip sqlite3 (push to n2e).zip]
Code:
adb shell mount -o rw,remount -t ext2 /dev/block/mmcblk0p5 /system
adb push sqlite3 /system/bin
download it from here:
http://forum.xda-developers.com/showpost.php?p=14747007&postcount=2
bobstro said:
Won't disabling the screensaver keep the screen and IR sensors active, thus eating up battery life significantly when not in use?
Click to expand...
Click to collapse
This makes a lot of sense... it explains my battery drain when the screen gets stuck on the "drag to unlock your NOOK" page after a reboot. Basically you have to make sure the Nook really goes to sleep.
Disabling the IR sensors and wifi are then the key to long battery life on the NST.
For anyone trying this technique: I used the pull/mod/push approach and Renate's recommendation of a -1 value, and everything seems to be working well, but I had to powercyle (power down, then power up) my Nook to get the change to take effect.

Power button ring led notifications?

OK guy & girls, does anybody know if,any kit kat rom, has a settings for it, to use with alerts, instead of downloading an app? I downloaded an app called ' button led ' it works, but it only lights up one led. The ring has 2 LEDs left, right.
helloyoufool said:
OK guy & girls, does anybody know if,any kit kat rom, has a settings for it, to use with alerts, instead of downloading an app? I downloaded an app called ' button led ' it works, but it only lights up one led. The ring has 2 LEDs left, right.
Click to expand...
Click to collapse
I am also waiting for something like this!
Everything I've read so far, the rear light has one white LED and can't be controlled, and with Lightflow I never could get the rear LED to do anything.
Front LED works good with Lightflow, but since I'm using AOKP I settled on using its built-in LED functionality even though it has a few limitations. Lightflow uses about 80M of ram, which is just insane.
khaytsus said:
Front LED works good with Lightwave,
Click to expand...
Click to collapse
I'm not finding this app. Can you share a link? Thanks.
LG G2
Here a link, to the app I'm using for my rear led alert
http://forum.xda-developers.com/showthread.php?t=1958939
20degrees said:
I'm not finding this app. Can you share a link? Thanks.
LG G2
Click to expand...
Click to collapse
Oops, I meant LightFLOW, editing my post
---------- Post added at 08:36 PM ---------- Previous post was at 08:34 PM ----------
helloyoufool said:
Here a link, to the app I'm using for my rear led alert
http://forum.xda-developers.com/showthread.php?t=1958939
Click to expand...
Click to collapse
Exactly what are you setting up in there to use the rear LED? What's the device path etc?
Nevermind, I found some stuff based on info in that thread and some other areas.
I still haven't figured out the (automated) rgb + blink stuff, but I can turn the left/right button on, torch on, red, green, or blue on. Blinking (without using sleep/usleep or such) and RGB I haven't yet figured out.
Yea that's the only that sucks.. Can't light the both LEDs, its either left or right.
helloyoufool said:
Yea that's the only that sucks.. Can't light the both LEDs, its either left or right.
Click to expand...
Click to collapse
Oh, no, I could light them independently but it seemed like turning one off turned off both. So I could go left, left off, right, right off, both.
I haven't decided what I'm going to do with the script I was playing with that night, but it was for fun. Especially flickering the torch at 50ms, etc. I figure at some point I'll use the stuff in Tasker.
How did you get them both to light up?
khaytsus said:
Oh, no, I could light them independently but it seemed like turning one off turned off both. So I could go left, left off, right, right off, both.
I haven't decided what I'm going to do with the script I was playing with that night, but it was for fun. Especially flickering the torch at 50ms, etc. I figure at some point I'll use the stuff in Tasker.
Click to expand...
Click to collapse
how did you do this?
antawnm26 said:
how did you do this?
Click to expand...
Click to collapse
Note, I'm on AOKP 4.3 with its kernel. These very well might not be exactly the same for all ROMs.
Attaching a script, it's just for playing, not really very useful at this point. Your device must be awake for the script to run properly, otherwise you'll find "sleep 1" (sleep 1 second) taking 5-10 seconds
If the devices in the script don't exist to play with, try find /sys | grep brightness to find them on your ROM.
green() etc turn it on the first time you hit the function, turn it off the next. The rear LEDs were a little weird, so I did them differently. They always show as 71 for some reason, where the others show 0 when they're off. Anyway, it works. I'm not checking any arguments, but some expect a second argument, and the third argument isn't used at all. Anyway, just an example, nothing you can directly use.
Code:
#!/bin/sh
rear_left="/sys/devices/leds-qpnp-d8117600/leds/button-backlight1/brightness"
rear_left_max="/sys/devices/leds-qpnp-d8117600/leds/button-backlight1/max_brightness"
rear_right="/sys/devices/leds-qpnp-d8117600/leds/button-backlight2/brightness"
rear_right_max="/sys/devices/leds-qpnp-d8117600/leds/button-backlight2/max_brightness"
red="/sys/devices/leds-qpnp-d8117200/leds/red/brightness"
red_max="/sys/devices/leds-qpnp-d8117200/leds/red/max_brightness"
blue="/sys/devices/leds-qpnp-d8117200/leds/blue/brightness"
blue_max="/sys/devices/leds-qpnp-d8117200/leds/blue/max_brightness"
green="/sys/devices/leds-qpnp-d8117200/leds/green/brightness"
green_max="/sys/devices/leds-qpnp-d8117200/leds/green/max_brightness"
torch="/sys/devices/leds-qpnp-d8117400/leds/led:flash_torch/brightness"
torch_max="/sys/devices/leds-qpnp-d8117400/leds/led:flash_torch/max_brightness"
# These could be useful for blink/rgb but not working from what I've found
# so far, but good info from the Tasker forum
# https://groups.google.com/forum/#!topic/tasker/pKWOQXZv7Hs/discussion
blink_patterns="/sys/devices/virtual/g2_rgb_led/use_patterns/blink_patterns"
input_patterns="/sys/devices/virtual/g2_rgb_led/use_patterns/input_patterns"
onoff_patterns="/sys/devices/virtual/g2_rgb_led/use_patterns/onoff_patterns"
pattern=$1
time_on=$2
time_off=$3
green()
{
echo "green"
if [ `cat $green_max` == `cat $green` ]; then
echo 0 > $green
else
echo `cat $green_max` > $green
fi
}
red()
{
echo "red"
if [ `cat $red_max` == `cat $red` ]; then
echo 0 > $red
else
echo `cat $red_max` > $red
fi
}
blue()
{
echo "blue"
if [ `cat $blue_max` == `cat $blue` ]; then
echo 0 > $blue
else
echo `cat $blue_max` > $blue
fi
}
rear_left()
{
if [ `cat $rear_left` -gt 0 ]; then
echo 0 > $rear_left
else
echo `cat $rear_left_max` > $rear_left
fi
}
rear_right()
{
if [ `cat $rear_right` -gt 0 ]; then
echo 0 > $rear_right
else
echo `cat $rear_right_max` > $rear_right
fi
}
torch()
{
if [ `cat $torch_max` == `cat $torch` ]; then
echo 0 > $torch
else
echo `cat $torch_max` > $torch
fi
}
flashtorch()
{
flashes=0
while [ $flashes -lt $time_on ]; do
let flashes=flashes+1
torch
usleep 50000
torch
usleep 40000
done
}
case $pattern in
testrear)
rear_left
sleep $time_on
rear_left
sleep $time_on
rear_right
sleep $time_on
rear_right
sleep $time_on
rear_left
rear_right
sleep $time_on
rear_left
rear_right
;;
testfront)
green
sleep 1
green
blue
sleep 1
blue
red
sleep 1
red
;;
testwhite)
red
green
blue
sleep 1
red
green
blue
;;
flashtorch)
flashtorch
;;
esac
N00b
Yo guys. Rooted my [email protected] with CloudyG2 and im wondering, how would i control my rear power button LED ring?
P.S, im kind of a noob with this stuff. Sorry for resurrecting this from 2013, i've been searching all over the web for something to control my LED ring
Naweed Reza said:
Yo guys. Rooted my [email protected] with CloudyG2 and im wondering, how would i control my rear power button LED ring?
P.S, im kind of a noob with this stuff. Sorry for resurrecting this from 2013, i've been searching all over the web for something to control my LED ring
Click to expand...
Click to collapse
Yes.. Me too. Pls help
Sent from my LG-D802 using XDA-Developers mobile app

[Q] Scheduled Shutdown

Hi,
I recently got fed up with forgetting to power off my nook. So I figured out I could use Tasker to shut it down at night when it is idle, etc., but I while I was testing it I realized that when my Nook is shut down, it shows the last state of the screen before having been shut down. It is quite annoying, especially that I cannot find a workaround, since Tasker cannot unlock the locked screen.
So, my question is, that does somebody know whether there is a shell command to power off the Nook like when you press the power off button?
Or any other suggestions would also be great.
In my experience letting the nook go into standby for 8-12 hours before using it again uses less battery than shutting down completely and rebooting it.
OB
Sent from my SPH-D710VMUB using Tapatalk 2
I use Quick Boot v4.2, Plus version which has an additional command useful for phones: Hot Boot. Free version is good enough for NST:
http://play.google.com/store/apps/details?id=com.siriusapplications.quickboot
I use a WiFi shutdown timer on my phone though, as sleep function on shoutcast radio.
P.S. As mentioned before in my apps listings thread for standby & screen blanking I use Screen Off FX:
http://play.google.com/store/apps/details?id=jp.co.kixx.tool.offwidget
Well, maybe I wasn't making myself clear enough. The most important part here is automation. So while screen off fx is awesome, I can't really use it in this situation since my screen is already locked when I want to turn my Nook off.
The thing I am searching for is a command or an app that could shut down my Nook (even when my screen is locked) in a way that it shows the usual "Your Nook has turned off completely" picture. (Every app that I tried has made the Nook show the screen that is has shown before having been shut down.) And I would like to do all of that automated, probably with Tasker.
Sagittarius0 said:
Well, maybe I wasn't making myself clear enough. The most important part here is automation. So while screen off fx is awesome, I can't really use it in this situation since my screen is already locked when I want to turn my Nook off.
Click to expand...
Click to collapse
The way I would do it is unlock the screen, overlay an image of whatever you want to be shown using a scene, and then shutdown.
To unlock the screen, try Simulating the "n" button command with tasker to unlock the screen before shutting down. (assuming slide to unlock is disabled):
Procedure for simulating button:
In your Tasker task, Create a new Run Shell Action. (Found in the "Script" category)
In the command section, put the following:
Code:
sendevent /dev/input/event1 1 102 1
sendevent /dev/input/event1 0 0 0
sendevent /dev/input/event1 1 102 0
sendevent /dev/input/event1 0 0 0
This will send a press and a release event of the n button.
​
Check the Use Root Option.
NOTE: If this is the first time you've used root with tasker, the root confirmation dialog will appear. Make sure to check the always allow option so that it doesn't pop up again.
Just For Reference:
If you would want to use other buttons do the following:
Replace 102 with:
Power Button: 116
Replace event1 with event0 AND 102 with:
Top Left Page Button: 412
Bottom Left Page Button: 139
Top Right Page Button: 407
Bottom Right Page Button: 158
Good Luck!
Absolutely woderful!
This is exactly how I wanted to do it. :victory:
It works perfectly, thank you very much.
Pushing stuff into /dev/input is lower level than it need be.
You'll be working with scan codes there.
In a shell this sends a press of the power button (using a KEYCODE)
Code:
input keyevent 26
Shutdown is easy enough (with one small hitch).
Simply send a android.intent.action.ACTION_REQUEST_SHUTDOWN
The problem is that this is a privileged intent and can only be sent by system apps.
System apps are those that have the system signature.
You can do that by re-signing your system.
You need to have android.permission.SHUTDOWN in the manifest.
You can do that by re-signing your system.
Click to expand...
Click to collapse
Well, how can I do that?
And does this command you mentioned have the same efect as reboot -p?
Sagittarius0 said:
Absolutely woderful!
This is exactly how I wanted to do it. :victory:
It works perfectly, thank you very much.
Click to expand...
Click to collapse
Glad I could help! :good:
Renate NST said:
Pushing stuff into /dev/input is lower level than it need be.
You'll be working with scan codes there.
In a shell this sends a press of the power button (using a KEYCODE)
Code:
input keyevent 26
Click to expand...
Click to collapse
Ok, good to know. I just went for the scan codes because I knew how to quickly get them from shell getevents.
Sagittarius0 said:
Well, how can I do that?
And does this command you mentioned have the same efect as reboot -p?
Click to expand...
Click to collapse
If all your looking for is to do a shutdown or reboot, and are already using a Tasker task, the action Misc > Reboot has the ability to shutdown or do a reboot. My guess is that it does exactly what Renate NST is telling you to do - send a shutdown intent - behind the scenes. Granted, I don't know, and I don't have Tasker installed on my nook so I can't confirm that it will actually work, I have just used Tasker on other devices and it seems to work fine.
Just seems like the easiest, cleanest way would be to keep all the actions under one roof.
cuff21 said:
I don't have Tasker installed on my nook so I can't confirm that it will actually work
Click to expand...
Click to collapse
It does work seamlessly.
cuff21 said:
My guess is that it does exactly what Renate NST is telling you to do - send a shutdown intent - behind the scenes.
Click to expand...
Click to collapse
Hmm, I don't know. A regular root and su won't work.
You'd either have to have a system-signed app or hack the permission system.
There is no clear info on the difference between an Android shutdown and a Linux shutdown.
Given the choice, I'd go for the Android shutdown.
Renate NST said:
Hmm, I don't know. A regular root and su won't work.
You'd either have to have a system-signed app or hack the permission system.
Click to expand...
Click to collapse
Well I had a stack overflow link that shows a way to do it, but I can't post links yet. Either way, apparently there is a way with only root. The code from the link was:
Code:
try {
Process proc = Runtime.getRuntime()
.exec(new String[]{ "su", "-c", "reboot -p" });
proc.waitFor();
} catch (Exception ex) {
ex.printStackTrace();
}

How to change power-off timeout on Nook Simple Touch?

Hi, does anyone know how to change the power-off timeout on the Nook Simple touch? When it automatically switches off and leaves a screen saying "Your Nook has been turned off to conserve battery power" or something.
I've looked in /data/data/com.android.providers.settings/databases/settings.db but there is no setting available.
Pkill-9 said:
Hi, does anyone know how to change the power-off timeout on the Nook Simple touch? When it automatically switches off and leaves a screen saying "Your Nook has been turned off to conserve battery power" or something.
I've looked in /data/data/com.android.providers.settings/databases/settings.db but there is no setting available.
Click to expand...
Click to collapse
What do you mean by "power-off timeout"? That screen appears only when you have intentionally shut down your device by long pressing the power button and then confirming through the onscreen dialog that you want to power off the device.
Or are you talking about the forced shutdown when the device decides there is not enough battery power to stay on?
The only "timeout" I can think of is the screensaver timeout which is found in Settings.
nmyshkin said:
What do you mean by "power-off timeout"? That screen appears only when you have intentionally shut down your device by long pressing the power button and then confirming through the onscreen dialog that you want to power off the device.
Or are you talking about the forced shutdown when the device decides there is not enough battery power to stay on?
The only "timeout" I can think of is the screensaver timeout which is found in Settings.
Click to expand...
Click to collapse
My Nook will shutdown at 60% battery power, or 40%, or 20% or something, and it will say that. I remember the word in particular is 'conserve'. I think when it's run out of battery it says something different.
Is there another way to have it shutdown after a period of time? I've seen a thread about using Tasker, but you have to purchase that from the Google Play store. I'd prefer to use a script or something.
Pkill-9 said:
My Nook will shutdown at 60% battery power, or 40%, or 20% or something, and it will say that. I remember the word in particular is 'conserve'. I think when it's run out of battery it says something different.
Is there another way to have it shutdown after a period of time? I've seen a thread about using Tasker, but you have to purchase that from the Google Play store. I'd prefer to use a script or something.
Click to expand...
Click to collapse
It should not be shutting down until it's in the 20's, maybe less. Something is not right--but you knew that.
The question is, hardware or software? If it's software and you do a backup, factory reset and restore the backup, you may be right back where you started. If it's hardware, nothing you do will fix it.
A third option is to do a factory restore and rebuild your system, rather than restore a potentially corrupted backup. That way if it's not hardware, you may solve the problem.
As an afterthought, there are some "battery recalibration" apps out there--not sure if any for Eclair, though. I'm a little leery of their promises, but it might be another thing to look into.
Tasker can do many things, but I'm not sure this is one of them. There is only one version that runs on the NST. PM me for more info if you want to go that route.
I think I will make an app that does what I want. Where can I find documentation on Android 2.1 and/or information on building an app for Android 2.1? I can't find any on google, nor and the official documentation seems to only be for the newest Android versions.
Pkill-9 said:
I'd prefer to use a script or something.
Click to expand...
Click to collapse
You can prepare custom tailored file named "debuglog.sh".
Then put it into /system/bin folder.
NST's android will run it every ~10 seconds.
ucy74 said:
You can prepare custom tailored file named "debuglog.sh".
Then put it into /system/bin folder.
NST's android will run it every ~10 seconds.
Click to expand...
Click to collapse
Thanks, this is working really well.
EDIT: I did it! I used wake locks to keep the script running when suspended, here is my final script, which will shutdown the nook if it is in sleep mode for a day:
Code:
#!/system/bin/sh
# debuglog.sh is an unused path, with a service definition in /init.rc that calls this file. init.rc can't be modified because the root filesystem is created from an
# I am using debuglog.sh for my shutdown script, and if I have any other scripts I want to run in the future, I can use it for that.
wakeup_timeout=86400
wait_until_sleep() {
cat /sys/power/wait_for_fb_sleep # https://stackoverflow.com/a/11275032
}
echo shutdown-on-sleep >/sys/power/wake_lock # Prevent this process from suspending when the device is suspended: https://stackoverflow.com/a/40518240
while
do
wait_until_sleep
timeout -t $wakeup_timeout cat /sys/power/wait_for_fb_wake
if [[ $? -ne 0 ]] ; then # If the command timed out, then it reached the scheduled shutdown timeout. If the command succeeded, then the Nook was awoken from it's slu
reboot -p
fi
done
I will check that running the script doesn't significantly increase battery consumption. If not, then this should be very very helpful in extending the battery life
---------------------------------------------------------------------------
Old post:
I've created a script, but I can't seem to get the NST to wakeup when scheduled. This is the script I am using:
Code:
#!/system/bin/sh
# debuglog.sh is an unused path, with a service definition in /init.rc that calls this file. init.rc can't be modified because the root filesystem is created from an image.
# I am using debuglog.sh for my shutdown script, and if I have any other scripts I want to run in the future, I can use it for that.
wakeup_timeout=60
get_current_unix_time() {
date '+%s'
}
set_wakeup_timeout() {
#echo $wakeup_timeout > /sys/power/wakeup_timer_seconds
echo $(expr $(get_current_unix_time) + $wakeup_timeout) > /sys/class/rtc/rtc0/wakealarm
}
wait_until_sleep() {
cat /sys/power/wait_for_fb_sleep # [url]https://stackoverflow.com/a/11275032[/url]
}
wait_until_wake() {
cat /sys/power/wait_for_fb_wake #
}
set_wakeup_timeout
while
do
wait_until_sleep
went_to_sleep=$(get_current_unix_time)
scheduled_wakeup=$(expr $(get_current_unix_time) + $wakeup_timeout)
wait_until_wake
if expr $(get_current_unix_time) \> $(expr $scheduled_wakeup - 5) ; then
reboot -p
fi
done
Pkill-9 said:
I did it!
Click to expand...
Click to collapse
You can check also parameters shown via
Code:
cat /sys/class/power_supply/bq27510-0/uevent
or drain percentage directly
Code:
cat /sys/class/power_supply/bq27510-0/capacity
but remember not to drain battery completely!
nook cannot wakup easily from case like this
So after running my script for the night, the battery has gone down by 11%, so running it with a wakelock is not a viable solution.
Ideally I could have the kernel schedule wake-ups, like I was trying before, but I can't seem to do that.
Apparently /dev/alarm is used by Android to schedule wakeups, but everything I find talks about using it from an app, instead of writing to it directly from commandline.
Pkill-9 said:
...battery has gone down by 11%...
Click to expand...
Click to collapse
What service/task would You like to keep running against battery saving? Epaper driver may be power hungry, but maybe You can turn off some android services or wifi driver?
ucy74 said:
What service/task would You like to keep running against battery saving? Epaper driver may be power hungry, but maybe You can turn off some android services or wifi driver?
Click to expand...
Click to collapse
The script is what eats up battery, nothing much I can do to improve it, it's running the 'timeout cat ...' command.
I'm a little late to the thread, but I use a simple app called AutoPowerOff to control this. It doesn't seem to have any affect on battery when the system is on.
AutoPowerOff for Android - APK Download
Download AutoPowerOff apk 1.0.2 for Android. Auto power off your device to save battery life.
apkpure.com
In the app itself, you can only set the timeout to a maximum of 23 hours 59 minutes. I wanted a bit of a longer timeout, though, and found that if you edit the app's settings XML file in /data/data, you can set whatever timeout you want. I use 72 hours, which is perfect for my habits. If I go three days without using my Nook, usually it means I'm going to go a few weeks. This way, I still have a nice charged battery when I do come back.

Categories

Resources