Turn screen off without Android sleeping 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 &gt; /dev/null'
echo "Tap power button 2x quickly to restore"
sleep $1
su -c 'echo 0 &gt; /sys/class/leds/lcd-backlight/brightness'


Make sure:


The device is rooted.
The script permissions are set to executable, e.g. by chmod 755 lcdoff.
The script is located in /system/bin (scripts cannot be executed from /storage).


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:


Total Commander
Tasker
Xposed Additions
your app of choice