Skip to content

Instantly share code, notes, and snippets.

@simonhaenisch
Last active February 15, 2018 00:51
Show Gist options
  • Save simonhaenisch/0ca8534bf50f189b4f93d1cc1f20c58f to your computer and use it in GitHub Desktop.
Save simonhaenisch/0ca8534bf50f189b4f93d1cc1f20c58f to your computer and use it in GitHub Desktop.
RPi: owncloud-synced slideshows with frame buffer #raspberrypi

Raspberry Pi: OwnCloud-Synced Slideshows with Frame Buffer

  • Install Arch Linux on the Raspberry Pi as explained in https://gist.github.com/simonhaenisch/d086156a5828c0037acd46b48279388f without alsa and shairport
  • Create an owncloud user rpi and share folders to be synced (without edit permissions)
  • Install owncloud-client: pacman -S owncloud-client
  • Install fonts package: pacman -S ttf-dejavu
  • Install Frame Buffer Image Viewer: pacman -S fbida
  • Install Cron: pacman -S cronie and enable auto-start: systemctl enable cronie
  • Create a folder /var/cloud to be synced to

Disable console blanking permanently (source):

echo -ne "\033[9;0]" >> /etc/issue

Disable HDMI overscan:

echo disable_overscan=1 >> /boot/config.txt

Use this command to do a sync:

owncloudcmd -u rpi -p ******** --non-interactive --silent /var/cloud https://cloud.example.com

Use this command to start a slideshow on virtual console 1 (-T 1) with a slide duration of 7 seconds (-t 7) and auto-zoom (-a), showing all .jpgs in the <slides-dir>:

fbi -noverbose -T 1 -a -t 7 -u `find /var/cloud/<slides-dir>/ -iname "*.jpg"`

To enable root auto-login after boot, run systemctl edit getty@tty1 to edit the first interactive shell service, and enter the following content:

[Service]
ExecStart=
ExecStart=-/usr/bin/agetty --autologin root --noclear %I $TERM

Edit /root/.profile to run the scripts (see below) on boot (for ssh sessions /root/.bashrc gets sourced instead of .profile):

loadkeys de
export EDITOR=nano
alias l="ls -al"

/root/sync.sh
/root/show.sh default

The show.sh script expects a folder structure like

/var/
  |-cloud/
      |- <slides-dir>/
          |- default/
          |- saturday/
              |- lunch/
              |- dinner/
          |- event/
          |- [...]

The slideshow for a certain sub-dir can be invoked by passing the path to the directory relative to the <slides-dir> as a command line argument, e.g. /root/show.sh saturday. It is possible to specify subdirs like /root/show.sh saturday/lunch.


sync.sh will replace the crontab with cronbjobs.txt inside the <slides-dir> after syncing the files with the cloud. An example cronbjobs.txt file could be:

25 10 * * 0 /root/sync.sh
30 10 * * 0 /root/show.sh
0  12 * * 6 /root/show.sh saturday/lunch
0  18 * * 6 /root/show.sh saturday/dinner
#!/bin/bash
# kill running slideshow
killall fbi &> /dev/null
# update this to point to your slides directory
basedir="/var/cloud/<slides-dir>"
defaultDir="default"
# get subdir from command line argument if given
if [ $# -eq 0 ]; then
subdir="$defaultDir"
else
subdir="$1"
fi
# combine to slide directory
slidesdir="$basedir/$subdir"
# check if dir exists
if [ ! -d "$slidesdir" ]; then
echo "Warning: could not find $slidesdir"
# else fall back to default dir
slidesdir="$basedir/$defaultDir"
echo "Falling back to $slidesdir"
fi
# run framebuffer image viewer on tty1 (-T 1)
fbi -noverbose -T 1 -a -t 7 -u `find $slidesdir -iname "*.jpg"`
#!/bin/bash
# sync with owncloud server
owncloudcmd -u rpi -p ******** --non-interactive --silent /var/cloud https://cloud.example.com
# update crontab
crontab /var/cloud/<slides-dir>/cronjobs.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment