Last active
November 18, 2018 10:08
-
-
Save gregdhill/49996aff020c2ca4c34e3b36731290df to your computer and use it in GitHub Desktop.
Raspberry Pi Display
This file contains 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 | |
# Instructions | |
# ------------ | |
# 1) Install Raspbian w/ LXDE | |
# 2) Boot Image | |
# 3) Configure Auto-Login | |
# 4) `curl ${RAW_GIST_URL} | bash` | |
# 5) Reboot & Attach Media | |
if ! type feh &> /dev/null; then | |
sudo apt-get install feh | |
fi | |
if ! type mplayer &> /dev/null; then | |
sudo apt-get install mplayer | |
fi | |
sudo cat <<EOF > /etc/rc.local | |
#!/bin/sh -e | |
( /home/pi/display.sh ) & | |
exit 0 | |
EOF | |
sudo cat <<EOF > /etc/xdg/lxsession/LXDE-pi/autostart | |
@lxpanel --profile LXDE-pi | |
@pcmanfm --desktop --profile LXDE-pi | |
@lxterminal | |
@xscreensaver -no-splash | |
point-rpi | |
EOF | |
cat <<EOF > /home/pi/.bashrc | |
nohup /home/pi/display.sh & | |
EOF | |
cat <<EOF > /home/pi/display.sh | |
main () { | |
media=$(df -h | grep media | awk '{print $6}') | |
if [[ "$media" == "" ]]; then | |
echo "Removable device not found." | |
return 1 | |
fi | |
content=$(ls $media | head -n 1) | |
if [[ "$content" == "" ]]; then | |
echo "No content to display." | |
return 1 | |
fi | |
advertisement=${media}/${content} | |
echo "Showing: ${advertisement}" | |
file ${advertisement} -i | grep 'png\|jpg\|jpeg' > /dev/null | |
if [[ $? -eq 0 ]]; then | |
feh --hide-pointer --full-screen --auto-zoom $advertisement | |
fi | |
file ${advertisement} -i | grep 'mp4' > /dev/null | |
if [[ $? -eq 0 ]]; then | |
mplayer -fs -loop 0 $advertisement | |
fi | |
} | |
while true; | |
do | |
main | |
sleep 5; | |
done | |
EOF | |
chmod +x /home/pi/display.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment