I’m just documenting a few things I did to make a non-interactable kiosk a bit more useful.
Hide the cursor
vim /var/lib/dietpi/dietpi-software/installed/chromium-autostart.sh
At the very bottom change the line
exec "$STARTX" "$FP_CHROMIUM" $CHROMIUM_OPTS "${URL:-https://dietpi.com/}"
to
exec "$STARTX" "$FP_CHROMIUM" $CHROMIUM_OPTS "${URL:-https://dietpi.com/}" -- -nocursor
Set the resolution
I hooked my pi up to a 1080p monitor.
vim /var/lib/dietpi/dietpi-software/installed/chromium-autostart.sh
At the top change CHROMIUM_OPTS
CHROMIUM_OPTS="--kiosk ... --window-size=${RES_X:-1920},${RES_Y:-1080}"
vim /boot/dietpi.txt
Change SOFTWARE_CHROMIUM_RES_X
and RES_Y
to the same resolution.
Adjust chromium kiosk startup arguments.
Add or remove whatever you want.
I didn’t really look into all of these, but there seems to be some recommended consensus on these arguments.
Some I also added.
vim /var/lib/dietpi/dietpi-software/installed/chromium-autostart.sh
CHROMIUM_OPTS="--kiosk --no-crash-upload --disable-breakpad --disable-crash-reporter --incognito --disable-translate --no-first-run --fast --fast-start --disable-features=TranslateUI --disk-cache-dir=/dev/null --disk-cache-size=1 --password-store=basic --start-fullscreen --noerrdialogs --disable-infobars --window-size=${RES_X:-1920},${RES_Y:-1080} --window-position=0,0"
Turn off the monitor
I used this to avoid burn-in on my monitor. I have it turn off certain hours every night.
Put this into a .sh script file and run with a cron job run from the root account.
Set the script to be executable.
If you run this script and the error is something about “Invalid MIT-MAGIC-COOKIE-1 key”, it means you probably need to run it from root.
#!/bin/sh
xset -display :0 s blank
xset -display :0 s reset
xset -display :0 s activate
Turn on the monitor
Also put this into a cron job using root account.
#!/bin/sh
xset -display :0 s reset
xset -display :0 s noblank
Restart chromium periodically
I do this because chromium can leak memory and if there’s an “Aw, Snap” error, it has no way of knowing and recovering. I set this script on a 4 hour cron job executed from a root crontab.
I first rename /var/lib/dietpi/dietpi-software/installed/chromium-autostart.sh to chromium-autostart-01.sh
I then create another script in the same directory called “chromium-autostart.sh” with the following contents (make sure it’s executable):
#!/bin/dash
export DISPLAY=:0
killall chromium-browse
sleep 10
/var/lib/dietpi/dietpi-software/installed/chromium-autostart-01.sh
It just kills the process, and restarts it. It also just continues to work even if the process doesn’t exist.
By using a level of indirection with this kill script, you can do nifty things such as have multiple URL’s on the kiosk and cycle between them periodically if you wanted.