Skip to content

Instantly share code, notes, and snippets.

@mschmitt
Last active May 9, 2020 21:53
Show Gist options
  • Save mschmitt/fc2cc6087082e49475d94dd5d07df3e0 to your computer and use it in GitHub Desktop.
Save mschmitt/fc2cc6087082e49475d94dd5d07df3e0 to your computer and use it in GitHub Desktop.
Raspbian kiosk script so I don't have to write it from scratch for the n+1th time.
# .config/lxsession/LXDE-pi/autostart
@lxpanel --profile LXDE-pi
@pcmanfm --desktop --profile LXDE-pi
@/home/pi/bin/kiosk.sh
#!/bin/bash
pkill chromium
#!/bin/bash
# -> .config/lxsession/LXDE-pi/autostart -> @/home/pi/bin/kiosk-runner
set -o monitor
printf kiosk-runner > /proc/$$/comm
export DISPLAY=:0
url="https://idefix.localnet.name/dashboard/"
function cleanup(){
echo "Killing child processes"
pkill --parent $$
echo "Exiting"
exit
}
trap cleanup INT QUIT TERM
xset s off
xset -dpms
xset s noblank
while true
do
# https://superuser.com/a/1206120/60094
sed -i 's/"exited_cleanly":false/"exited_cleanly":true/' ~/.config/chromium/'Local State'
sed -i 's/"exited_cleanly":false/"exited_cleanly":true/; s/"exit_type":"[^"]\+"/"exit_type":"Normal"/' ~/.config/chromium/Default/Preferences
chromium-browser --incognito \
--process-per-site \
--check-for-update-interval=604800 \
--start-fullscreen "${url}" &
wait
done
#!/bin/bash
# Cron: * * * * * /home/pi/bin/kiosk-supervisor >/dev/null 2>&1
# Stop the kiosk when connected TV can't be pinged
tv='tv-office.localnet.name'
me="$(basename $0)"
printf "${me}" > /proc/$$/comm
if [[ ! -e /tmp/tv-up && ! -e /tmp/tv-down ]]
then
touch /tmp/tv-down
fi
function cleanup(){
echo "Killing child processes"
pkill --parent $$
echo "Exiting"
exit
}
trap cleanup INT QUIT TERM
if ping -c 5 "${tv}"
then
touch /tmp/tv-up
rm -f /tmp/tv-down
logger -t "${me}" -p user.info 'TV up.'
if ! pkill -0 kiosk-runner
then
logger -t "${me}" -p user.info 'Starting kiosk.'
/home/pi/bin/kiosk-runner &
disown -a
fi
else
touch /tmp/tv-down
rm -f /tmp/tv-up
logger -t "${me}" -p user.info 'TV down.'
if pkill -0 kiosk-runner
then
logger -t "${me}" -p user.info 'Stopping kiosk.'
pkill kiosk-runner
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment