1

I'm wondering if there is a way to make this two tools working together. I can make Xscreensaver to run omxplayer with some video when the time for screensaver to hit is on, but then I can't stop it... only way is to kill the process.

With mplayer it works fine except it is cooking the Pi and generally nowhere near omxplayer performance.

I was thinking if its possible to have Xscreensaver run a script that would start omxplayer and kill it when somebody touch the screen or press key basically when screensaver ends....

In general my idea was to use the Pi 3 with my touch screen as info kiosk where user can click and check stuff.. but when nothing is happening I wanted it to play video and when somebody touch the screen again it will show the kiosk mode of chromium... maybe I'm going on it the wrong way ?

1 Answer 1

3

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!)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.