for my application I've set up xscreensaver ('sudo apt-get install xscreensaver' and reboot, use 'xscreensaver-demo' to configure it) to blank my 7" eGalax touchscreen after 10 minutes, but when it's left unattended for 12 hours the backlight is still on. The screen sleeping options don't work in xscreensaver, so I rolled my own solution.
I'd appreciate suggestions if it isn't the best solution. It should work for others too.
Step 1 - Create scripts that manually turn off and on the HDMI
- create file hdmi_off.sh
- create file hdmi_on.sh (make sure to set executable permissions on both - 'chmod 755 *sh')
You should make sure these scripts work from the command line for you - all my other script does is call them, so if these do not work it will not work. Stop here until you get them working. You'll have to search the forums to find how to make your screen come on, and start displaying stuff.
Step 2 - Create a perl script to detect the screensaver state
Basically we can use "xscreensaver-command -watch" to follow text output of what xscreensaver is doing. What I do is detect when the screensaver becomes active, then start a timer to determine when to turn the screen off. It is a lot simpler if you just want the screen to power off immediately. But I wanted this dual off approach as it takes the screen longer to come on when its fully off.
Step 3 - make the script run all the time
Make an inittab entry to make the perl script run all the time ('sudo vi /etc/inittab' and add the line to the bottom
Save the file, exit the editor, and then type 'sudo init q' to make the system re-read the file. 'ps -ef' should now list your script.