Because of its lean and fan less design the Raspberry Pi is a perfect piece of hardware to create a simple slideshow system or so called Digital Signage Server (DSS). Perfect to drive a LCD somewhere to teaser the latest offers or new products.
Introduction
It doesn’t matter what kind of Raspberry Pi we use It works with all versions quite well. First we need to install Raspbian on the Pi. We can use a Raspbian Image or the NOOB SD-Card the choice is yours. Images can be found at https://www.raspberrypi.org/downloads/
After the Pi is connected to a screen, keyboard and mouse we insert the SD-Card and power it up.
Installation
The installer wants to know if we want to use the GUI or the console. We keep booting into the console. All other questions can be answered with the default answers. We set the network settings to fit our network.
Right after the first reboot we login with our Pi User and use the raspi-config tool to activate the ssh daemon.
There are some packages we need to install manually.
apt-get install x11-xserver-utils feh
Deactivate energy saving mode
In the default setting, the screen is turned of after a couple of minutes. To always display our slide show we have to turn this feature off. To do that we insert the following settings right after the second line of /etc/X11/xinit/xinitrx.
xset s off xset -dpms xset s noblank
New user
We create a new user to be used as the slide show user. With this account we’ll also upload the images to be displayed. This user will be automatically logged in after the Pi is started. For now we call it newuser.
adduser newuser
We write down the password. A public key setup may be used as well of course.
Autologin
To enable autologin after each reboot we’ll edit /etc/inittab and lookup the following line.
1:2345:respawn:/sbin/getty 115200 tty1
We change that to:
#1:2345:respawn:/sbin/getty 115200 tty1 1:2345:respawn:/bin/login -f newuser tty1 /dev/tty1 2>&1
Next we’ll make another change to /etc/rc.local and add right before exit 0 a new line:
su -l newuser-c startx exit 0
Now XServer is started with our new user.
With the next reboot the GUI should be started with user newuser.
The feh slide show script
In the newusers home directory we create the following script:
#!/bin/bash FOLDER="Desktop/Pictures/" TEMPF="/tmp/slideshow"; export DISPLAY=":0" if [ -d $FOLDER ] then MD5C=$(ls -al $FOLDER | md5sum | awk '{ print $1 }'); else echo "Error: Folder does not exist"; fi; case $1 in start) feh --quiet -Z -F -Y --slideshow-delay 12 $FOLDER & echo $MD5C > $TEMPF ;; stop) pgrep -f "feh" > /dev/null && kill `pgrep -f "feh"` && rm $TEMPF ;; restart) $0 stop && $0 start ;; status) if [ $(pgrep -f "feh") ] then echo "Slideshow running"; exit 0; else echo "Slideshow not running"; exit $? fi ;; cron) if [ -e /tmp/slideshow ] then MD5O=$(cat /tmp/slideshow) if [ $(pgrep -f "feh") ] then # Passt true else $0 start; fi else echo "Slide show not started or $TEMPF vanished" exit 0 fi # Changes made = restart if [[ $MD5O != $MD5C ]] then echo $MD5C > /tmp/slideshow $0 stop $0 start exit 0 fi ;; *) echo "Usage: $0 {start|stop|reload|cron}"; exit 2 ;; esac
The script supports four parameters: start, stop, restart and cron. Start and Stop we can use right now. If there are some pictures in Desktop/Pictures and we call the script with start the slide show should start right away. If needed we can change the delay right in the script.
The Script should be put into the cron table with parameter cron. This way it’ll check if there are new or changed images and if necessary restart the slide show.
To start the slide show right away we create a small autostart file for our window manager LXDE.
[Desktop Entry] Name=Slideshow Exec=/home/newuser/slideshow.sh start Terminal=false Type=Application
After the next reboot the slide show should start right away. The following cron entry will check for new files. We use crontab -e to edit the file.
* * * * * /home/newuser/slideshow.sh cron
This is about it.