CI / test (push) Successful in 2m25s
- New desktop module gamerig-library (components/gamerig-library, logic in lib/gamelib): the layout of gamerig's web library (desktop/ui) in draw ops. Top bar with the Gamerig mark, app count and search; sidebar with categories and counts, running apps (switch to, stop) and rig status (GPU, display, audio); card grid with featured games two columns wide, icon tiles, category and status badges, description, install hint, Launch / Big Picture / Switch to / Stop. Typing filters, arrows + Enter launch, the wheel scrolls. Colours: follow desktop, dark, light. - New game-library capability: tables 26-28 (status, games, launch modes), request 45, in the wasmer/wasmtime stub, the MoonBit wasmhost and the Rust host-wasm. - compositor/shell/gamelib.mbt polls GET $GAMERIG_DESKTOP_API/api/state (default http://127.0.0.1:8091) every 2 s with curl on a socket and POSTs launch/stop/focus; a file:// base reads a state file (tests). - --desktop NAME picks what fills the desktop at start. scripts/gamerig-kiosk.sh now runs a hybrid kiosk with the library as the desktop (CHANDRA_KIOSK_MODE=strict for the old one). - Tests: lib/gamelib, compositor/host/gamelib_test.mbt, a host-wasm test; docs/gamerig-library.md with a screenshot. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DPL5hgvjzw8hHirxRsXSsE
99 lines
4.9 KiB
Bash
Executable File
99 lines
4.9 KiB
Bash
Executable File
#!/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 as a hybrid kiosk (the default, CHANDRA_KIOSK_MODE=hybrid): panel,
|
|
# dock and Alt+Tab work, the desktop is the Gamerig Library module (docs/gamerig-library.md),
|
|
# which reads and drives server.py through the shell; Log out and power are locked. No WebKit.
|
|
# CHANDRA_KIOSK_MODE=strict runs the old single-app kiosk instead: no panel, no shortcuts, the
|
|
# library app (shell_window.py as a Wayland client of Chandra) fullscreen and restarted.
|
|
# * 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_MODE (hybrid or strict),
|
|
# CHANDRA_KIOSK_APP (strict: 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}
|
|
MODE=${CHANDRA_KIOSK_MODE:-hybrid}
|
|
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/"}
|
|
|
|
export GAMERIG_DESKTOP_API=${GAMERIG_DESKTOP_API:-http://127.0.0.1:$PORT}
|
|
case "$MODE" in
|
|
strict) KIOSK_ARGS="--kiosk"; echo "kiosk app: $APP" ;;
|
|
*) MODE=hybrid; KIOSK_ARGS="--kiosk-hybrid --desktop gamerig-library"; APP="" ;;
|
|
esac
|
|
echo "chandra: $CHANDRA_DIR DISPLAY=$DISPLAY XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR mode=$MODE"
|
|
echo "library daemon: $GAMERIG_DESKTOP_API"
|
|
[ "${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, $MODE)" >>"$LOG"
|
|
if [ "$MODE" = strict ]; then
|
|
./wasmhost compositor.wasm --x11 --fullscreen --app-id gamerig-desktop \
|
|
--socket "$XDG_RUNTIME_DIR/wayland-chandra" --kiosk "$APP" >>"$LOG" 2>&1
|
|
else
|
|
# shellcheck disable=SC2086
|
|
./wasmhost compositor.wasm --x11 --fullscreen --app-id gamerig-desktop \
|
|
--socket "$XDG_RUNTIME_DIR/wayland-chandra" $KIOSK_ARGS >>"$LOG" 2>&1
|
|
fi
|
|
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
|