Last active
July 12, 2019 12:06
-
-
Save sshimko/486e1b4a279cd49ee6e5255836e32832 to your computer and use it in GitHub Desktop.
Raspberry Pi Picture Frame
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 | |
cd /usr/share/icons | |
# Microseven MYM7 1080i-A etc | |
wget -O cam1.jpg 'http://192.168.0.2/tmpfs/snap.jpg?usr=username&pwd=password&1562769315776' | |
wget -O cam2.jpg 'http://192.168.0.3/tmpfs/snap.jpg?usr=username&pwd=password&1562769315776' | |
wget -O cam3.jpg 'http://192.168.0.4/tmpfs/snap.jpg?usr=username&pwd=password&1562769315776' | |
# foscam 9821 v2 | |
wget -O cam4.jpg 'http://192.168.0.5/cgi-bin/CGIProxy.fcgi?cmd%3DsnapPicture2%26usr%3Dsuername%26pwd%3Dpassword' |
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
[Desktop Entry] | |
Name=Foscam 9821 Cam4 | |
Comment=Foscam | |
Icon=/usr/share/icons/cam4.jpg | |
Exec=/usr/bin/cvlc --zoom=0.62 rtsp://username:[email protected]:443/videoMain | |
Type=Application | |
Encoding=UTF-8 | |
Terminal=false | |
Categories=None; |
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
[Desktop Entry] | |
Name=Microseven Cam1 | |
Comment=Microseven Cam1 | |
Icon=/usr/share/icons/cam1.jpg | |
Exec=/usr/bin/gst-launch-1.0 playbin uri=rtsp://username:[email protected]/11 uridecodebin0::source::latency=0 | |
Type=Application | |
Encoding=UTF-8 | |
Terminal=false | |
Categories=None; |
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
[Desktop Entry] | |
Type=Application | |
Name=Slideshow | |
Exec=sh -c '/bin/bash /home/pi/pictureframe.sh' |
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 | |
finish() | |
{ | |
pkill -9 $PPID | |
} | |
trap finish EXIT TERM INT | |
export DISPLAY=:0.0 | |
export XAUTHORITY=/home/pi/.Xauthority | |
echo '"pkill -n feh"' > /dev/shm/xbindkeys.feh | |
echo "b:1" >> /dev/shm/xbindkeys.feh | |
# enumerate all the attached screens | |
displays="" | |
while read id | |
do | |
displays="$displays $id" | |
done< <(xvinfo | sed -n 's/^screen #\([0-9]\+\)$/\1/p') | |
delay=$1 | |
checkFullscreen() | |
{ | |
# loop through every display looking for a fullscreen window | |
for display in $displays | |
do | |
#get id of active window and clean output | |
activ_win_id=`DISPLAY=:0.${display} xprop -root _NET_ACTIVE_WINDOW` | |
activ_win_id=${activ_win_id:40:9} | |
# Check if Active Window (the foremost window) is in fullscreen state | |
isActivWinFullscreen=`DISPLAY=:0.${display} xprop -id $activ_win_id | grep _NET_WM_STATE_FULLSCREEN` | |
if [[ "$isActivWinFullscreen" != *NET_WM_STATE_FULLSCREEN* ]];then | |
xbindkeys -n -f /dev/shm/xbindkeys.feh & | |
xbk_pid=$! | |
feh -V -x -F -Y -Z -z -A slideshow --reload 600 -r /home/pi/Pictures -D 7 | |
kill -9 $xbk_pid > /dev/null | |
# kills apps that shouldnt be long running, e.g., a security cam feed that should close v. continuing to run | |
# killall gst-launch-1.0 cvlc vlc 2>&1 > /dev/null | |
# | |
# updates cam icons and viola the icons update on the desktop too | |
/home/pi/camicons.sh 2>&1 >/dev/null | |
fi | |
done | |
} | |
# If argument empty, use 60 seconds as default. | |
if [ -z "$1" ];then | |
delay=60 | |
fi | |
# If argument is not integer quit. | |
if [[ $1 = *[^0-9]* ]]; then | |
echo "The Argument \"$1\" is not valid, not an integer" | |
exit 1 | |
fi | |
IDLE_TIME=$(($delay*1000)) | |
while sleep $((1)); do | |
idle=$(xprintidle) | |
if [ $idle -ge $IDLE_TIME ]; then | |
checkFullscreen | |
fi | |
done | |
rm /dev/shm/xbindkeys.feh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The idea here is to create a centra console to monitor my security cameras, alarm system, and home automation system from a Raspberry Pi. All we need is a few simple scripts and desktop entries.
The pictureframe.sh script uses feh in a loop and binds the mouse button to kill feh. This is useful for touchscreens where you want the slideshow to exit when you touch the screen then resume automatically later. It checks to see how long X has been idle and starts after a configurable delay. The X code I found somewhere else (thanks to whoever did it!)
As written, put the desktop file in /home/pi/.config/autostart and pictureframe.sh in /home/pi and images in /home/pi/Pictures
The desktop files:
Other things I added are desktop entries for my home automation system’s webpage and my alarm system’s webpage.