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 dietpi’s account.
Set the script to be executable. (I use 755 and group/user to dietpi)
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 but this should not be necessary.
#!/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 dietpi’s account.
#!/bin/sh
xset -display :0 s reset
xset -display :0 s noblank
Check if Chrome is Misbehaving
The purpose of this is because chrome doesn’t know when a page fails to load or there’s some other issue with the page. WARNING: The script below hard codes 7 to be the number of processes I expect to be running at all times with my specific Dakboard webpage I’m displaying. If it’s less than this amount, it will reboot. You need to use htop or something to see how many chromium processes you expect to be running on your kiosk with your specific kiosk webpage. Anything below this amount will cause the raspberry pi to reboot. I did this because sometimes a chromium process or several may crash or fail to load. My kiosk displays a webpage with about 10 chromium processes when it’s working properly. So, for me, if it’s below 7, then I know something is definitely screwed up. If you set this too low, your pi will keep rebooting, so just be careful. It’s hacky I know…
Create a script called “checkchromecrash.sh” with (permissions 755, group and owner is dietpi) in the dietpi user directory somewhere with the following contents:
#!/bin/bash
RES=$(ps -aux | grep -c chromium)
if [ "${RES}" -lt 7 ]; then
sudo shutdown -r now
fi
Setup the crontab
Using the dietpi user, I type in crontab -e to edit the crontab with the following contents:
0 10 * * * sudo shutdown -r now
5 * * * * /home/dietpi/kiosk/checkchromecrash.sh
0 1 * * * /home/dietpi/kiosk/turnoffmonitor.sh
0 9 * * * /home/dietpi/kiosk/turnonmonitor.sh
- 1 am the monitor should shut off. (Added bonus, the cpu usage and temps drop to minimal).
- 9 am the monitor should turn on.
- Every 5 minutes it checks to see if chrome is screwed up and reboots the Rpi if it is.
- 10 am the Rpi will reboot. Chrome leaks memory quite drastically on my Dakboard kiosk page, so a reboot is necessary for me or it will start crashing and doing weird stuff. You may or may not need this.
- I was able to get away with NOT putting anything in the root’s crontab. So it should be empty.
Disable auto update
When it checks for updates, it sometimes fails and kills chromium for some reason and then displays the command line. So I decided to not let it auto update and this is a lot more stable. So you’ll have to remember to manually update it.
sudo vim /boot/dietpi.txt
Search for the auto update lines and change them to 0.
CONFIG_CHECK_DIETPI_UPDATES=0
...
CONFIG_CHECK_APT_UPDATES=0
Final Notes
- If you update dietpi’s packages, make sure you do a full reboot of the Rpi or the monitor scripts won’t work. Not 100% why.