Toggle RPF 7" touchscreen backlight with screensaver - Printable Version +- OpenMarine (https://forum.openmarine.net) +-- Forum: OpenPlotter (https://forum.openmarine.net/forumdisplay.php?fid=1) +--- Forum: How I did it (https://forum.openmarine.net/forumdisplay.php?fid=6) +--- Thread: Toggle RPF 7" touchscreen backlight with screensaver (/showthread.php?tid=2177) |
Toggle RPF 7" touchscreen backlight with screensaver - natoryous - 2019-12-29 Following up on my own question in http://forum.openmarine.net/showthread.php?tid=2174 here's how I'm currently controlling the backlight on the official Raspberry Pi Foundation 7" touchscreen (v1.1) via xscreensaver. It's not the perfect solution, but close enough for now. I'm still looking into whether I can make this into a proper xscreensaver module that can be distributed as a single file. Using a script I found and edited, I launch a process to watch xscreensaver and toggle the backlight when xscreensaver blanks and unblanks the display. This means if you install the xscreensaver package, you can configure the screen blanking time from the GUI, turn it on or off entirely, and the RPi display backlight will respond to those changes. The process starts automatically on boot. I'll write down the entire installation procedure in case anyone wants to try it out. To install xscreensaver, do Code: sudo apt-get install xscreensaver Edit a new file, I'll call it backlight_control.sh. I use nano: Code: nano ~/backlight_control.sh Input the following Code: #!/bin/sh Save the file. Now to make the script executable Code: chmod +x ~/backlight_control.sh To launch the script as a process automatically on reboot, edit this file: Code: sudo nano /etc/xdg/lxsession/LXDE-pi/autostart Add the following line. Make sure it's below the line that reads "@xscreensaver -no-splash"; xscreensaver-command needs to be started after xscreensaver. Code: @sudo /home/pi/backlight_control.sh & The '&' makes sure the script can exit, leaving the new process running in the background. Save the file and reboot your Pi. The backlight should turn off when the screensaver blanks the screen, and turn back on upon keyboard, mouse or touch input. If anyone has any suggestions on how to improve this or a better solution, feel free to pitch in. Some notes:
Fair winds, Andy |