Fedora kiosk

By gill, 17 August, 2023

Install gnome kiosk (gdm, zenity, and firefox should already be installed).

sudo dnf install -y gnome-kiosk-script-session

Create the user and give them a password.

sudo useradd -c "TV user" -m tvuser

sudo passwd tvuser

Modify the GDM configuration to automatically login the user on startup. Edit /etc/gdm/custom.conf to add these:

[daemon]
AutomaticLoginEnable=True
AutomaticLogin=tvuser

Now you can login from the login screen. After typing the password, but before logging in, choose Kiosk from the menu on the lower right.

Run Firefox once to make sure you have its settings correct.

Create the script for the kiosk to run in /home/tvuser/.local/bin/gnome-kiosk-script. Here's the script I use for kiosk mode. It runs as tvuser. You'll have to tweak it for the addresses and Firefox profile locations.

!/bin/sh
# This script is located in ~/.local/bin.
# It's provided as an example script to show how
# the kiosk session works.  At the moment, the script
# just starts a text editor open to itself, but it
# should get customized to instead start a full screen
# application designed for the kiosk deployment.
# gedit ~/.local/bin/gnome-kiosk-script

# exec "$0" "$@"

function grace() {
 echo Exiting gracefully
 rm /var/tmp/kiosk-lock
 exit 0
}

trap grace SIGTERM SIGKILL SIGHUP USR1

while [ -f /var/tmp/kiosk-lock ]; do
 zenity --warning --timeout=29 --text="Unclean shutdown. Lock file /var/tmp/kiosk-lock exists. PID=$$ here."
 systemctl --user stop org.gnome.Kiosk.Script.service
 exit 0
done

touch /var/tmp/kiosk-lock

## Check connectivity to tank.fishparts.net first
## Keep looping until it can connect

#nc -z weather.fishparts.net 80
nc -z tank.fishparts.net 80
RC=$?
while [ $RC -ne 0 ]
do
 #nc -z weather.fishparts.net 80
 nc -z tank.fishparts.net 80
 RC=$?
 sleep 11
done
## Remove Firefox lock files if they are leftover from before
for f in /home/tvuser/.mozilla/firefox/vcgeu9es.default-release/lock /home/tvuser/.mozilla/firefox/vcgeu9es.default-release/.parentlock
do 
 [ -f $f ] && rm -f $f
done

## Start Firefox in kiosk mode to weather page
while true; do
 #firefox -kiosk http://weather.fishparts.net/loopdata/index.html
 firefox -kiosk http://tank.fishparts.net/big-weather
 # Give firefox time to start up
 sleep 17
 # Keep sleeping while firefox is running
 # Because Firefox forks even in kiosk mode
 while [ -n "$(pidof firefox)" ]
 do 
   sleep 19
   [ -f /var/tmp/kiosk-lock ] && rm /var/tmp/kiosk-lock
 done
done
 

Private
Yes