#!/bin/sh
# The kiosk session: Cage on tty1 with the client as its only application; systemd starts it again whenever it ends.
set -u

# Cage takes its keyboard layout from the environment, which localed keeps in /etc/default/keyboard.
if [ -r /etc/default/keyboard ]; then
    . /etc/default/keyboard
fi
export XKB_DEFAULT_LAYOUT="${XKBLAYOUT:-us}"
export XKB_DEFAULT_MODEL="${XKBMODEL:-}"
export XKB_DEFAULT_VARIANT="${XKBVARIANT:-}"
export XKB_DEFAULT_OPTIONS="${XKBOPTIONS:-}"
export XDG_CURRENT_DESKTOP=computle-kiosk
export XDG_SESSION_DESKTOP=computle-kiosk
export GDK_BACKEND=wayland
# A kiosk has no desktop portal backend; GTK would otherwise wait out a 50 s settings timeout before the first frame.
export GDK_DEBUG=no-portals
export GTK_A11Y=none

# -d: no client-side decorations; VT switching stays off (no -s), so the console cannot be reached from the keyboard.
exec /usr/bin/cage -d -- /usr/lib/computle-stream/kiosk/computle-kiosk-app
