feat(ai-arena): Add X11 rendering flag for screen capture compatibility

Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
Claude Code 2026-04-10 21:35:17 -07:00
parent dca1a32a6f
commit 7db5447968

View file

@ -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" \