Last active
December 17, 2021 02:36
-
-
Save freshlogic/62c36008cd647ff929add95778036870 to your computer and use it in GitHub Desktop.
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 | |
# Install updates | |
sudo apt update -y | |
sudo apt -qq upgrade -y | |
sudo apt -qq autoremove -y > /dev/null | |
# Install Chromium | |
sudo apt install -y chromium-browser unclutter | |
# Disable overscan if necessary | |
printf "Do you see a black border around the screen [y/N]:" | |
read black_border | |
if [[ $black_border == "y" ]]; then | |
# Create a backup file before modifying | |
sudo cp /boot/config.txt /boot/config.txt.bkp | |
sudo sed -i 's/#disable_overscan=1/disable_overscan=1/' /boot/config.txt | |
fi | |
AUTOSTART_PATH=$HOME/.config/lxsession/LXDE-pi | |
mkdir -p $AUTOSTART_PATH | |
cat > $AUTOSTART_PATH/kiosk.sh <<EOF | |
#!/bin/bash | |
# Turn off screensaver and disable energysaver | |
xset -dpms | |
xset s noblank | |
xset s off | |
while true; | |
do | |
# Remove the mouse cursor after 10 seconds of idleness | |
unclutter -idle 10 -grab & | |
# Ensure that if we have a power cut or bad shutdown that the chromium preferences are reset to a "good" state so we don't get the restore previous session dialog | |
sed -i 's/"exited_cleanly":false/"exited_cleanly":true/' $HOME/.config/chromium/Default/Preferences | |
sed -i 's/"exit_type":"Crashed"/"exit_type":"Normal"/' $HOME/.config/chromium/Default/Preferences | |
# Kill all Chromium processes | |
pkill -o chromium | |
chromium-browser --autoplay-policy=no-user-gesture-required --disable-extensions --no-default-browser-check --start-fullscreen \ | |
https://morningsave.com/stores/preston-shepard-place/displays/0002 & | |
sleep 60 | |
done | |
EOF | |
chmod +x $AUTOSTART_PATH/kiosk.sh | |
if [[ ! -f $AUTOSTART_PATH/autostart ]]; then | |
# We are clear to clone the current autostart | |
cp /etc/xdg/lxsession/LXDE-pi/autostart $AUTOSTART_PATH/autostart | |
echo "@$AUTOSTART_PATH/kiosk.sh" >> $AUTOSTART_PATH/autostart | |
else | |
if grep -Fxq "@$AUTOSTART_PATH/kiosk.sh" $AUTOSTART_PATH/autostart; then | |
echo "[SKIP] kiosk mode already setup" | |
else | |
echo "@$AUTOSTART_PATH/kiosk.sh" >> $AUTOSTART_PATH/autostart | |
fi | |
fi | |
sudo reboot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment