Kiosk mode: --kiosk CMD runs one fullscreen app, locked down, restarted when it exits
CI / test (push) Successful in 4m10s

No panel, no compositor shortcuts or desktop menus, the focused window
fullscreen (dialogs float), CMD restarted with backoff. Ctrl+Alt+Shift+Escape
or chandra-ctl kiosk lock|unlock|status for admin work. --app-id sets the X11
WM_CLASS / Wayland app id of Chandra's own window. scripts/gamerig-kiosk.sh
runs Chandra as a gamerig rig's library window on its NVIDIA Xorg.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hgvjzw8hHirxRsXSsE
This commit is contained in:
Claude committed 2026-11-26 02:22:03 +00:00
1 parent 4920f505e5
commit d521d0d840
11 files changed
+635 -16

No files matched your search

+84
View File
@@ -0,0 +1,84 @@
#!/bin/sh
# Run Chandra as the home screen of a gamerig rig (docs/kiosk-gamerig.md).
#
# On a rig, gamerig's onstart.sh brings up headless NVIDIA Xorg, Openbox, the library daemon
# (server.py on 127.0.0.1:8091) and Selkies, which streams the X screen. This script puts Chandra
# on that X screen in place of gamerig's own library window (shell_window.py, an X11 GTK window):
#
# * Chandra is one X client: a fullscreen window under Openbox whose WM_CLASS is gamerig-desktop,
# so gamerig's Openbox rules, Ctrl+Alt+L / Super+Space ("back to the library", wmctrl -xa) and
# server.py's focus calls find it exactly as they found the old window.
# * Inside it, Chandra runs in kiosk mode: no panel, no shortcuts, the library app fullscreen and
# restarted when it exits. Until there is a native launcher module the library app is the same
# shell_window.py, now a Wayland client of Chandra (GTK + WebKit on wl_shm).
# * Games and Steam don't go through Chandra: server.py starts them on Xorg with the NVIDIA
# driver, Openbox stacks them above Chandra, Selkies captures and injects input (XTest) as before.
#
# Usage (as root on the rig, after onstart.sh is up):
# gamerig-kiosk.sh replace the running library window with Chandra, and keep it running
# gamerig-kiosk.sh --check only print what it would use
#
# Environment: CHANDRA_DIR (default /opt/chandra: wasmhost, compositor.wasm, components/, wit/,
# config/, assets/, lib/), GAMERIG_DESKTOP_DIR (default /opt/gamerig-desktop), GAMERIG_DESKTOP_PORT
# (8091), DISPLAY (default: the first X socket), CHANDRA_KIOSK_APP (the app run in the kiosk;
# default gamerig's library window).
set -u
CHANDRA_DIR=${CHANDRA_DIR:-/opt/chandra}
GAMERIG_DESKTOP_DIR=${GAMERIG_DESKTOP_DIR:-/opt/gamerig-desktop}
PORT=${GAMERIG_DESKTOP_PORT:-8091}
LOG=${CHANDRA_KIOSK_LOG:-/var/log/chandra-kiosk.log}
if [ -z "${DISPLAY:-}" ]; then
for s in /tmp/.X11-unix/X*; do
[ -e "$s" ] || continue
DISPLAY=":${s##*/X}"
break
done
fi
export DISPLAY
export XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR:-/tmp/runtime-chandra}
mkdir -p "$XDG_RUNTIME_DIR" && chmod 700 "$XDG_RUNTIME_DIR"
# The library app inside the kiosk. Chandra starts it with WAYLAND_DISPLAY set and DISPLAY unset,
# so GTK picks Wayland. WebKit gets no DMA-BUF renderer and no sandbox in a container (as onstart.sh).
APP=${CHANDRA_KIOSK_APP:-"env WEBKIT_DISABLE_DMABUF_RENDERER=1 WEBKIT_DISABLE_SANDBOX_THIS_IS_DANGEROUS=1 NO_AT_BRIDGE=1 python3 $GAMERIG_DESKTOP_DIR/shell_window.py --url http://127.0.0.1:$PORT/"}
echo "chandra: $CHANDRA_DIR DISPLAY=$DISPLAY XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR"
echo "kiosk app: $APP"
[ "${1:-}" = "--check" ] && exit 0
if [ ! -x "$CHANDRA_DIR/wasmhost" ] || [ ! -f "$CHANDRA_DIR/compositor.wasm" ]; then
echo "gamerig-kiosk: no Chandra build in $CHANDRA_DIR (wasmhost, compositor.wasm)" >&2
exit 1
fi
# Stop gamerig's own library window: first its supervisor (onstart.sh's run_library_window_supervisor,
# a bash subshell that is the window's parent), then the window, so it isn't reopened.
for pid in $(pgrep -f "$GAMERIG_DESKTOP_DIR/shell_window.py" 2>/dev/null); do
ppid=$(awk '{print $4}' "/proc/$pid/stat" 2>/dev/null)
# run_with_dbus may sit between them: walk up to the supervising bash.
while [ -n "$ppid" ] && [ "$ppid" -gt 1 ]; do
case "$(cat "/proc/$ppid/comm" 2>/dev/null)" in
bash|onstart.sh) kill "$ppid" 2>/dev/null; break ;;
esac
ppid=$(awk '{print $4}' "/proc/$ppid/stat" 2>/dev/null)
done
kill "$pid" 2>/dev/null
done
# Keep Chandra running: started again (after a second, then backing off to 30 s) if it exits.
cd "$CHANDRA_DIR" || exit 1
export LD_LIBRARY_PATH="$CHANDRA_DIR/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
delay=1
while true; do
start=$(date +%s)
echo "$(date -u +%FT%TZ) starting chandra (kiosk)" >>"$LOG"
./wasmhost compositor.wasm --x11 --fullscreen --app-id gamerig-desktop \
--socket "$XDG_RUNTIME_DIR/wayland-chandra" --kiosk "$APP" >>"$LOG" 2>&1
rc=$?
[ $(( $(date +%s) - start )) -ge 30 ] && delay=1
echo "$(date -u +%FT%TZ) chandra exited ($rc); again in ${delay}s" >>"$LOG"
sleep "$delay"
delay=$(( delay * 2 > 30 ? 30 : delay * 2 ))
done