#!/usr/bin/env bash # Log the two signals `skip_intro.sh` decides on, every second, through a whole # boot -- WITHOUT pressing anything. # # Why: skip_intro only runs the title test when the frame is static, gated at # `rmse <= 1500`. A 381 s run measured 1503 and 1549 -- just above the cut -- so # the title test was never called and the one allowed press was never spent. # The fix is NOT to nudge 1500; a threshold moved to make one run pass is fitted # to a single sample. This produces the distribution the gate should be chosen # from: for every second, the frame-to-frame RMSE and the green-glyph count, # which are independent measurements of "is this a static frame" and "is this # the interactive title". # # Output is TSV on stdout: seconds, rmse, glyph_px. set -u export HOME=/sylph-home/re DISP="${DISPLAY:-:98}" SD="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" alive(){ ps -o pid=,stat= -C xenia_canary 2>/dev/null | awk '$2 !~ /^Z/ {print $1}'; } until xdotool search --name "Xenia-canary" >/dev/null 2>&1; do [ -n "$(alive)" ] || { echo "# EMULATOR GONE before the window appeared" >&2; exit 4; } sleep 1 done printf 'secs\trmse\tglyph\n' deadline=$(( SECONDS + ${1:-600} )) while [ $SECONDS -lt $deadline ]; do rm -f /tmp/bt1.png /tmp/bt2.png screenshot /tmp/bt1.png >/dev/null 2>&1; sleep 0.6 screenshot /tmp/bt2.png >/dev/null 2>&1 # Same liveness guard as skip_intro: two STALE files compare to a constant # non-zero RMSE, which reads exactly like a playing movie. if [ ! -s /tmp/bt1.png ] || [ ! -s /tmp/bt2.png ]; then echo "# SCREENSHOT FAILED at ${SECONDS}s" >&2; exit 5 fi [ -n "$(alive)" ] || { echo "# EMULATOR GONE at ${SECONDS}s" >&2; exit 4; } d=$(compare -metric RMSE /tmp/bt1.png /tmp/bt2.png null: 2>&1 | sed 's/ .*//' | cut -d. -f1) g=$(python3 "$SD/is_title.py" /tmp/bt2.png 400 2>/dev/null | sed 's/[^0-9]*\([0-9]*\).*/\1/') printf '%s\t%s\t%s\n' "$SECONDS" "${d:-0}" "${g:-0}" sleep 1 done