Raspberry Pi Picture

Photo Slideshows Using Raspberry Pi And feh

Background

At a family event just shy of a year ago I wanted to set up a slideshow (two in fact) to run continuously. The event was outdoors and leaving two laptops exposed to the elements for an extended period of time was obviously not very appealing. So instead a couple of Raspberry Pis together with the feh image viewer proved to be the perfect fit.

System Info

These instructions assume a fresh install of Raspbian using either the official Raspbian imager or by using the NOOBS installer.

  • Pi: Raspberry Pi 3
  • OS: Raspbian 9 (Stretch)
  • Desktop: LXDE

Feh Installation and Test

The first step is to install the feh program. Raspbian uses the APT package management so installation is as simple as:

apt-get install feh

Next, in order to run feh in the way we want, enter the following command in the terminal:

feh \
    --recursive \
    --randomize \
    --fullscreen \
    --quiet \
    --hide-pointer \
    --slideshow-delay 6 \
    yourPicDir

The command line switches are for the most part self-explanatory. The idea is to give feh a directory containing pictures you've copied to the Pi and then have it cycle through them randomly, displaying each for six seconds. Other options are documented in the man pages if you'd like to customize the usage.

To exit the slideshow press the Esc key.

Disabling Screen Blanking

By default the screen will blank after a few minutes of mouse and keyboard inactivity. In order to disable the screen blanking we'll need to modify the lightdm.conf file:

nano /etc/lightdm/lightdm.conf

and add the following line under the [Seat:*] section:

xserver-command=X -s 0 dpms

Auto-Start Slideshow On Boot

To have the slideshow automatically start on boot, first create a small shell script file to hold the feh command:

nano /home/pi/slideshow.sh

and paste the following:

#!/bin/bash

feh \
    --recursive \
    --randomize \
    --fullscreen \
    --quiet \
    --hide-pointer \
    --slideshow-delay 6 \
    yourPicDir

Be sure to make the new shell script executable:

chmod 755 /home/pi/slideshow.sh

And finally add it to the pi user's LXDE autostart file:

echo "@/home/pi/slideshow.sh" >> /home/pi/.config/lxsession/LXDE-pi/autostart

When you reboot your Raspberry Pi it should now automatically start the slideshow.

To exit the slideshow, hit the Esc key and you will see the normal LXDE desktop.