Skip to content

Instantly share code, notes, and snippets.

@jonasbits
Created August 21, 2019 09:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonasbits/8a5f95538370760fadbe74afaa3b3bd7 to your computer and use it in GitHub Desktop.
Save jonasbits/8a5f95538370760fadbe74afaa3b3bd7 to your computer and use it in GitHub Desktop.
konstpaj umeahackerspace autoplay video on rpi
#Umeå Hackerspace konstpaj self-explanatory configuration file
term=1
xres=1920
yres=1080
# auto=0, analogue=1, hdmi=2
aout=0
vol=0
background="black.ppm"
videofolder="videos"
@reboot /usr/local/sbin/konstpaj.sh
sudo apt install omxplayer fbset
cp /boot/konstpaj/konstpaj.sh /usr/local/sbin/
chmod 755 /usr/local/sbin/konstpaj.sh
mkdir -p /mnt/konstusb/videos/
cp /boot/konstpaj/black.ppm /mnt/konstusb/
#add crontab and systemd-service install here
#!/bin/bash
# do whatever the fuck you want license /Umeå Hackerspace
MOUNTDRIVE="/dev/sda1"
KONSTROOT="/mnt/konstusb"
KONSTCONFIG="${KONSTROOT}/config"
DEFAULTBG="black.ppm"
mkdir -p "${KONSTROOT}"
mount "${MOUNTDRIVE}" "${KONSTROOT}"
cd "${KONSTROOT}" || (echo could not cd into "${KONSTROOT}" | tee /var/log/konstpaj.log && exit 1)
if [ ! -f "${DEFAULTBG}" ]; then
# create background
cat <<EOF > "${DEFAULTBG}"
P1
1 1
1
EOF
# end of background
fi
if [ ! -f "${KONSTCONFIG}" ]; then
#create config file
cat <<EOF > "${KONSTCONFIG}"
#Umeå Hackerspace konstpaj self-explanatory configuration file
term=1
xres=1920
yres=1080
# auto=0, analogue=1, hdmi=2
aout=0
vol=0
background="${DEFAULTBG}"
videofolder="videos"
EOF
# end of config
fi
if [ "x" = "x$aout" ]; then
aout=0
fi
. /mnt/konstusb/config
if [ ! -d "${videofolder}" ]; then
mkdir "${videofolder}"
fi
fbset -xres "${xres}" -yres "${yres}"
(sleep 2; amixer cset numid=3 "$aout")&
(sleep 5; fbi -T "${term}" -noverbose "${background}")&
#(cd "${KONSTROOT}" && . "${KONSTCONFIG}" && while true; do sleep 1; processes=$(pgrep fbi|wc -l) ; if [ $processes -eq 0 ]; then fbi -T "${term}" -noverbose "${background}"; fi ; done)&
omxplayer --loop --vol "$vol" "${videofolder}"/*.mp4
[Unit]
Description=Mount USB with video for konstpaj
[Mount]
What=/dev/sda1
Where=/mnt/konstusb
Type=vfat
Options=defaults
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment