Ok so there is virtually no info about how to successfully pair xscreensaver
and omxplayer
, so I took it as a challenge and came up with a workaround, that actually works. :D
What needs to be done:
Set xscreensaver
to blank and set the "Blank After" to time you want the screensaver to kick in...
https://i.sstatic.net/jNJWv.png
Create a small script and stuff it somewhere, /etc/
is as good a place as any
touch /etc/video_screensaver.sh
chmod +x /etc/video_screensaver.sh
Edit the file and add the following
#!/bin/bash
process() {
while read input; do
case "$input" in
UNBLANK*) killall omxplayer.bin ;; # This will kill the omxplayer process
BLANK*) omxplayer --loop --no-osd --no-keys /home/pi/Desktop/Video/Guardians.mp4 & ;; # Don't forget the & on the end or it will never stops, just add your movie file path
esac
done
}
/usr/bin/xscreensaver-command -watch | process
This little script/daemon utilises xscreensaver-command -watch
and looks for a change of state. We will need to have it start on boot. I'm using Raspbian from NOOBS so I edited this file:
vi ~/.config/lxsession/LXDE-pi/autostart
by adding this line to the end:
@/etc/video_screensaver.sh
My whole autostart file for my kiosk looks like this:
@lxpanel --profile LXDE-pi
@pcmanfm --desktop --profile LXDE-pi
@xscreensaver -no-splash
@point-rpi
@xset s off
@xset -dpms
@xset s noblank
@sed -i 's/"exited_cleanly": false/"exited_cleanly": true/' ~/.config/chromium Default/Preferences
@chromium-browser --noerrdialogs --kiosk --kiosk-printing https://google.sk --incognito --disable-translate
@/etc/video_screensaver.sh
Works unbelievably great on my Pi 3, the script is not taxing the CPU at all. It works fine with my touch screen.
I have been testing it now for 4 hours and my Pi is happily staying at <60°C with no cooling, whilst playing loop trailers... The CPU usage is staying very low (about 3% per core while playing), compared to mplayer
, it's a day and night difference.
One more thing that can be useful and easily added is to have it play a video file at random from a folder on each screensaver start...
One more edit note, if you're using kiosk mode with chromium
you might want to disable this two lines in ~/.config/lxsession/LXDE-pi/autostart
#@lxpanel --profile LXDE-pi
#@pcmanfm --desktop --profile LXDE-pi
I found out that clicking for long enough on the top of where the taskbar is, will show it and let you escape chromium... (make sure you have ssh access to enable it again if you need it!)