Is there any way to quickly toggle the screen off without making Android sleep?
For example, I sometimes like to use the Calm app when I sleep. But it keeps the screen on all the time. When I just use that app for 10 minutes, it's great that it keeps the screen on; but if I'm sleeping for hours, I would like the app to keep on running (playing sounds) and turn the screen off.
How can this be done?
Credit goes to Firelord for the basic method. Here is a time-delay shell script that turns off the backlight for my device, and apparently others' as well.
Create a file named "lcdoff" and copy the following into it:
#!/system/bin/sh if [ -z "$1" ]; then echo "usage: `basename $0` delay" exit fi su -c 'echo getsu > /dev/null' echo "Tap power button 2x quickly to restore" sleep $1 su -c 'echo 0 > /sys/class/leds/lcd-backlight/brightness'
chmod 755 lcdoff.
/system/bin(scripts cannot be executed from
Then open a terminal app and enter
lcdoff 10, to turn off the screen after a 10-second delay,
lcdoff 30 for a 30-second delay, etc. To ensure that the processor stays on, simply enable the Android developer option "Stay Awake". Edit: Stay Awake only works while plugged into a power source -- see this answer for an alternative.
If you don't want to type the command in a terminal, you can launch the script as a custom action in:
I had some trouble with the accepted answer as I'm not hugely familiar with shell scripting on Android/Unix/Linux so I thought I'd add my experience here for anyone in a similar boat.
To get this working with Tasker or similar the line you need is:
echo 0 > /sys/class/leds/lcd-backlight/brightness
For tasker put this in the 'command' field with 'Use Root' enabled, works like a charm. To disable simply switch the zero out for a 1, ergo:
echo 1 > /sys/class/leds/lcd-backlight/brightness
or lock and unlock the device.
So to answer your question about quickly toggling this behavior. Assign each of the above commands to a tasker task, then you can make use of the new long-press intercept in the latest tasker version to toggle the screen on and off without putting the device to sleep. Alternatively you can assign the command to a profile which triggers when your conditions are met.