Skip to content

Instantly share code, notes, and snippets.

@mscalora
Created July 4, 2017 22:13
Show Gist options
  • Save mscalora/135270ed5d0519b49244b1aaf5a8e153 to your computer and use it in GitHub Desktop.
Save mscalora/135270ed5d0519b49244b1aaf5a8e153 to your computer and use it in GitHub Desktop.
display slideshow on raspberry pi
#! /usr/bin/env bash
COUNT=$(ls -1 data/ | wc -l)
NUM=$(python -c 'import time; print (int(time.time())/600%'${COUNT}'+1)')
NUM2=$(expr $(date "+%s") / 600 % \( $COUNT + 1 \) )
echo -n "Run what=$NUM when=$(date) pi=$NUM vs sh=$NUM2 $NUM:$NUM2"
HOME=${HOME-:/home/pi}
DELAY=8
if pgrep fehplus ; then
# create link to correct album
ln -s /home/pi/data/$NUM $HOME/show_temp
# atomicly replace show link
mv -Tf $HOME/show_temp $HOME/show
# tell fehplus to rescan directory
kill -SIGURG $(pgrep fehplus)
sleep 1
if pgrep fehplus ; then
echo "Looks like fehplus is running: $(pgrep fehplus)"
exit 0
fi
echo "fehplus needs to be restarted"
else
echo "fehplus was no running and needs to be restarted"
fi
export DISPLAY=:0.0
/usr/local/bin/fehplus -FZpr --hide-pointer -D $DELAY $HOME/show &>$HOME/fehout.log </dev/null &
PID=$!
#echo $PID >$HOME/feh.pid
echo " pid=$PID"
sleep 1
echo " feh out:"
sed -e's/^/--->/' $HOME/fehout.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment