Skip to content

Instantly share code, notes, and snippets.

@gbrayut
Created October 30, 2023 17:37
Show Gist options
  • Save gbrayut/88b1212e994a5fd2b3c39e9efae4c209 to your computer and use it in GitHub Desktop.
Save gbrayut/88b1212e994a5fd2b3c39e9efae4c209 to your computer and use it in GitHub Desktop.
Raspberry Pi Slideshow using feh and systemd user service unit
#Flash 32bit os using rpi imager (with ssh and wifi settings) then login via ssh and configure device
ssh-import-id-gh gbrayut
sudo apt update
sudo apt install -y vim feh
sudo apt upgrade -y
# Copy pictures to rpi
scp -r /path/to/slideshow gbrayut@gbrpi3b:~/
# Configure systemd user unit file
mkdir -p ~/.config/systemd/user/
scp slideshow.service gbrayut@gbrpi3b:~/.config/systemd/user/
systemctl --user daemon-reload
systemctl --user disable slideshow;systemctl --user enable slideshow.service
systemctl --user start slideshow.service
systemctl --user status slideshow.service
# Prevent screen timeout (NOTE these were added to the service unit)
export DISPLAY=:0
xset -dpms & xset s off & xset s noblank
# Test crash or stop service
sudo pkill feh
systemctl --user stop slideshow
# Modify service
vim ~/.config/systemd/user/slideshow.service
systemctl --user daemon-reload; systemctl --user restart slideshow
[Unit]
Description=Slideshow using feh
After=graphical.target
[Service]
Environment=DISPLAY=:0
Environment=XAUTHORITY=/home/gbrayut/.Xauthority
#Type=forking
ExecStartPre=/bin/bash -c '/bin/sleep 5; xset -dpms; xset s off; xset s noblank'
ExecStart=/usr/bin/feh --quiet --preload --recursive --full-screen --auto-zoom --reload 60 -Y --slideshow-delay 9.0 ${HOME}/slideshow
Restart=always
RestartSec=5
[Install]
WantedBy=default.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment