Created
January 21, 2017 20:00
-
-
Save mojoaxel/f3b60b5f242e746dbc0f6c0c8f40eb1b to your computer and use it in GitHub Desktop.
Raspberry Pi LXDE Slideshow
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
STICK_A="/media/pi/AF7C-CF1E"; | |
STICK_B="/media/pi/IMAGES"; | |
TEMPF="/home/pi/slideshow.tmp"; | |
DELAY=5; | |
export DISPLAY=":0" | |
if [ -d "$STICK_A" ]; then | |
FOLDER=$STICK_A; | |
fi | |
if [ -d "$STICK_B" ]; then | |
FOLDER=$STICK_B; | |
fi | |
if [ -d "$FOLDER" ]; then | |
MD5C=$(ls -al $FOLDER | md5sum | awk '{ print $1 }'); | |
else | |
echo "Error: Folder does not exist"; | |
exit 1; | |
fi; | |
case $1 in | |
start) | |
feh --quiet --auto-zoom --fullscreen --hide-pointer --recursive --image-bg white --slideshow-delay $DELAY $FOLDER & | |
echo $MD5C > $TEMPF | |
;; | |
stop) | |
pgrep -f "feh" > /dev/null && kill `pgrep -f "feh"` && rm $TEMPF | |
;; | |
toggle) | |
if [ -e "$TEMPF" ]; then | |
echo "Stopping Slideshow"; | |
$0 stop | |
else | |
echo "Starting Slideshow"; | |
$0 start | |
fi | |
;; | |
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 "$TEMPF" ]; then | |
MD5O=`cat $TEMPF`; | |
# Check is feh is running | |
if [ $(pgrep -f "feh") ]; then | |
echo "feh is still running" | |
else | |
echo "feh is not running; restart slideshow" | |
$0 start | |
fi | |
# Changes made = restart | |
if [ "$MD5O" != "$MD5C" ]; then | |
echo "Image folder changed; restart!" | |
echo $MD5C > $TEMPF; | |
$0 restart | |
exit 0 | |
fi | |
else | |
echo "Slide show not started or $TEMPF vanished" | |
exit 0 | |
fi | |
;; | |
*) | |
echo "Usage: $0 {start|stop|reload|cron}"; | |
exit 2 | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment