BAD!!! DPMS is not properly implemented on Raspberry Pi! No worries, that is a quick fix, albeit a hacky one. At least it is possible.
20191227/DuckDuckGo raspberry pi display mode power save
20191227/https://unix.stackexchange.com/questions/52263/how-can-i-put-my-hdmi-display-into-and-out-of-power-save-mode
20191227/https://github.com/raspberrypi/linux/issues/487
As for the Raspberry Pi Foundation, well they are going to have to stop complaining about not having the software development resources to be able to implement DPMS proper, because they need to make way for the influx of full-time Raspberry Pi desktop computer users coming their way.
20191227/DuckDuckGo raspberry pi power off monitor after inactivity tvservice
20191227/https://www.screenly.io/blog/2017/07/02/how-to-automatically-turn-off-and-on-your-monitor-from-your-raspberry-pi/
20191227/DuckDuckGo xorg get activity counter
20191227/https://askubuntu.com/questions/202136/how-can-a-script-detect-a-users-idle-time
So, the solution! A partial solution for testing if vcgencmd
display_power
does what you want is this script. Note that vcgencmd
display_power
is similar to tvservice -o
and tvservice -p
, but
better.
#! /bin/sh
# Timeout in milliseconds.
TIMEOUT=60000
MODE=on
while true; do
IDLE=`xprintidle`
if [ $IDLE -gt $TIMEOUT -a "$MODE" = "on" ]; then
vcgencmd display_power 0
MODE=off
fi
if [ $IDLE -lt $TIMEOUT -a "$MODE" = "off" ]; then
vcgencmd display_power 1
MODE=on
fi
sleep 2
done
If this is not powering off and on your display properly after the
designated timeout in milliseconds, then you need to search for some
different power control commands to use. Otherwise, you can move on
to implementing this as a systemd
service. To do this, you need to
be able to determine which user is owning the display at a particular
time so that you can route the power control commands accordingly.
20191227/DuckDuckGo find user owns display 0 xorg
20191227/https://unix.stackexchange.com/questions/74635/which-user-owns-x-display
#! /bin/sh
export DISPLAY=:0
# Timeout in milliseconds.
TIMEOUT=720000
MODE=on
while true; do
XUSER=`ps -eaf | grep LXDE | head -n1 | awk '{ print $1; }'`
IDLE=`sudo -u $XUSER xprintidle`
if [ $IDLE -gt $TIMEOUT -a "$MODE" = "on" ]; then
sudo -u $XUSER vcgencmd display_power 0
MODE=off
fi
if [ $IDLE -lt $TIMEOUT -a "$MODE" = "off" ]; then
sudo -u $XUSER vcgencmd display_power 1
MODE=on
fi
sleep 2
done
Name it /usr/local/bin/goodscreen.sh
. Now write a systemd
unit
file, to start it like you would from /etc/rc.local
:
[Unit]
Description=Run goodscreen screen saver.
[Service]
ExecStart=/usr/local/bin/goodscreen.sh
[Install]
WantedBy=multi-user.target
Name it /etc/systemd/system/goodscreen.service
.
Now you’re in business for more serious desktop computing use!