Skip to content

Instantly share code, notes, and snippets.

@pallas
Last active October 15, 2020 00:50
Show Gist options
  • Save pallas/188d8767ec8521d7f4414efd061cf12e to your computer and use it in GitHub Desktop.
Save pallas/188d8767ec8521d7f4414efd061cf12e to your computer and use it in GitHub Desktop.
Raspberry Pi screensaver (feedback) + Pandora (pianobar) + AirPlay (rpiplay) kiosk
#!/bin/bash
# SPDX-License-Identifier: Unlicense
# Author: Derrick Lyndon Pallas <derrick@pallas.us>
#
# /etc/rc.local: xinit /usr/lib/kiosk.sh &
#
# http://rss-glx.sourceforge.net/
# https://github.com/PromyLOPh/pianobar
# https://github.com/FD-/RPiPlay
xset s off
xset -dpms
xset s noblank
modprobe snd_bcm2835 && aplay /usr/share/sounds/alsa/Noise.wav
while true ; do
pidof pianobar && killall -SIGCONT pianobar || tmux new -d -s pianobar -- /bin/sh -c 'nice -n -10 aoss pianobar'
pidof feedback && killall -SIGCONT feedback || ( nice -n -5 /usr/lib/xscreensaver/feedback --root & )
timeout 1s killall -w -SIGTERM rpiplay || timeout 1s killall -w -SIGHUP rpiplay || killall -SIGKILL rpiplay || true
vcgencmd cache_flush
env \
MALLOC_CONF=junk:true \
LD_PRELOAD=/usr/lib/arm-linux-gnueabihf/libjemalloc.so.2 \
DISPLAY=:0.0 \
nice -n -15 rpiplay -n DerSpiegel -b auto -l 2>&1 | tee /dev/kmsg &
while ! lsof -i -sTCP:ESTABLISHED | grep rpiplay >/dev/null ; do
sleep 1
for P in rpiplay pianobar feedback ; do
pidof $P || continue 3
done
done
# echo on 0 | cec-client RPI -s -d 1
# echo ping | cec-client RPI -s -d 1
# echo as | cec-client RPI -s -d 1
killall -SIGSTOP pianobar feedback || true
while lsof -i -sTCP:ESTABLISHED | grep rpiplay >/dev/null ; do sleep 1 ; done
# echo is | cec-client RPI -s -d 1
done
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment