From 7db54479682a905f8c4fc675550361971fce8ece Mon Sep 17 00:00:00 2001 From: Claude Code Date: Fri, 10 Apr 2026 21:35:17 -0700 Subject: [PATCH] =?UTF-8?q?feat(ai-arena):=20=E2=9C=A8=20Add=20X11=20rende?= =?UTF-8?q?ring=20flag=20for=20screen=20capture=20compatibility?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Lilith Autocommit --- tools/ai-arena.sh | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/tools/ai-arena.sh b/tools/ai-arena.sh index ad61cc0a..4acbc3e4 100755 --- a/tools/ai-arena.sh +++ b/tools/ai-arena.sh @@ -28,19 +28,21 @@ TURN_LIMIT=150 TURN_DELAY="0.3" SEED_LIST="" RESULTS_DIR="" +FORCE_X11=0 usage() { sed -n '2,17p' "$0" | sed 's/^# \{0,1\}//' exit 0 } -while getopts "n:t:d:s:o:h" opt; do +while getopts "n:t:d:s:o:xh" opt; do case "$opt" in n) N="$OPTARG" ;; t) TURN_LIMIT="$OPTARG" ;; d) TURN_DELAY="$OPTARG" ;; s) SEED_LIST="$OPTARG" ;; o) RESULTS_DIR="$OPTARG" ;; + x) FORCE_X11=1 ;; h|*) usage ;; esac done @@ -167,9 +169,27 @@ for ((i = 0; i < N; i++)); do echo "[launch] $MATCH_ID seed=$SEED pos=($POS_X,$POS_Y) $P1 vs $P2" + # -x forces Godot to render via XWayland instead of native Wayland + # so host-level screenshot tools (ffmpeg x11grab) can capture the + # windows. Without this flag, native Wayland sessions show black + # when grabbed via X11. Default is native Wayland — faster and + # what the user will normally see. + # + # Implementation detail: flatpak manifests include --socket=wayland + # by default, which makes the sandbox connect to the host Wayland + # compositor regardless of the WAYLAND_DISPLAY env var. The only way + # to force XWayland is to pass --nosocket=wayland to `flatpak run`, + # which revokes the Wayland permission for this invocation only. + WAYLAND_ARGS=() + if [ "$FORCE_X11" -eq 1 ]; then + WAYLAND_ARGS=(--nosocket=wayland --socket=x11) + fi + WAYLAND_DISPLAY="${WAYLAND_DISPLAY:-wayland-0}" \ XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR:-/run/user/$(id -u)}" \ + DISPLAY="${DISPLAY:-:0}" \ flatpak run --user \ + "${WAYLAND_ARGS[@]}" \ --env=AI_ARENA=true \ --env=AI_ARENA_MATCH_ID="$MATCH_ID" \ --env=AI_ARENA_SEED="$SEED" \