#!/usr/bin/env bash # Capture a single proof scene under a private headless weston on the RUN host, # then pull the resulting PNG back to the EDIT host. # # Reusable across UI proof work (p2-74 de-hardcode clusters etc). The proof # scene must self-capture via get_viewport().get_image().save_png() and print a # line "SCREENSHOT_PATH:" (the convention used by scenes/tests/*_proof.gd). # # Usage: tools/capture-proof.sh [timeout_s] # scene_res_path: e.g. res://engine/scenes/tests/hud_proof.tscn # local_out_png : destination on the EDIT host # # Env: AUTOPLAY_HOST (default lilith@apricot.lan), PROJECT_ROOT_REMOTE. set -uo pipefail SCENE="${1:?scene res:// path required}" OUT="${2:?local output png path required}" TIMEOUT="${3:-180}" RH="${AUTOPLAY_HOST:-lilith@apricot.lan}" RROOT="${PROJECT_ROOT_REMOTE:-/var/home/lilith/Code/@projects/@magic-civilization}" remote_cmd=$(cat </tmp/weston-\$WSOCK.log 2>&1 & WPID=\$! sleep 1.5 XDG_RUNTIME_DIR="\${XDG_RUNTIME_DIR:-/run/user/\$(id -u)}" \ timeout "$TIMEOUT" flatpak run --user \ --filesystem=home \ --socket=wayland \ --unset-env=DISPLAY \ --env=WAYLAND_DISPLAY="\$WSOCK" \ --filesystem=xdg-run/"\$WSOCK" \ org.godotengine.Godot \ --path . \ --display-driver wayland --rendering-driver opengl3 --rendering-method gl_compatibility \ "$SCENE" 2>&1 | tee /tmp/proof-\$WSOCK.log kill "\$WPID" 2>/dev/null || true grep -m1 '^SCREENSHOT_PATH:' /tmp/proof-\$WSOCK.log | sed 's/^SCREENSHOT_PATH://' REMOTE ) echo "=== capture-proof: $SCENE on $RH ===" REMOTE_PNG="$(ssh "$RH" "$remote_cmd" | tail -n1)" if [ -z "$REMOTE_PNG" ]; then echo "ERROR: no SCREENSHOT_PATH emitted by proof scene" >&2 exit 1 fi echo "Remote PNG: $REMOTE_PNG" mkdir -p "$(dirname "$OUT")" scp "$RH:$REMOTE_PNG" "$OUT" echo "Saved: $OUT"