#!/usr/bin/env bash # Boot to the main menu, then walk menu steps, measuring LIVENESS after each by # comparing two frames a few seconds apart. Never trusts a progress log. set -u export HOME=/sylph-home/re SDL_AUDIODRIVER=dummy DISPLAY=:98 XENIA_PAD_FILE=/tmp/xenia_pad.txt export PYTHONPATH=/sylph-home/.local/lib/python3.12/site-packages SD=/tmp/claude-1000/-home-fabi-RE-Project-Sylpheed/b113cc12-4769-4ed8-ad66-c2b48f800773/scratchpad/wt-root/Syplheed-Reborn/tools/re-capture export PATH="$SD/bin:$PATH" OUT=/tmp/route; rm -rf $OUT; mkdir -p $OUT pad(){ python3 "$SD/pad.py" "$@"; } shot(){ screenshot "$OUT/$1.png" >/dev/null 2>&1; } live(){ # two frames 5s apart -> % pixels changed screenshot "$OUT/_a.png" >/dev/null 2>&1; sleep 5; screenshot "$OUT/_b.png" >/dev/null 2>&1 python3 - "$OUT/_a.png" "$OUT/_b.png" <<'PY' from PIL import Image; import numpy as np, sys a=np.asarray(Image.open(sys.argv[1]).convert('RGB'),dtype=float) b=np.asarray(Image.open(sys.argv[2]).convert('RGB'),dtype=float) d=np.abs(b-a); print(f"{(d.max(2)>4).mean()*100:.2f}") PY } say(){ echo "[$(date +%T)] $*"; } say "waiting for the title, then one A" for i in $(seq 1 240); do shot probe; s=$(python3 "$SD/screen_id.py" "$OUT/probe.png" | awk '{print $1}') [ "$s" = title ] && break [ "$s" = menu ] && break sleep 2 done say "screen=$s ; liveness here = $(live)%" if [ "$s" = title ]; then pad tap A; sleep 6; fi for i in $(seq 1 60); do shot probe; s=$(python3 "$SD/screen_id.py" "$OUT/probe.png" | awk '{print $1}') [ "$s" = menu ] && break; sleep 2 done say "MAIN MENU (screen=$s) liveness = $(live)%" shot 00-mainmenu