diff --git a/scripts/run-headless.sh b/scripts/run-headless.sh index 838a6d9..b2081c8 100755 --- a/scripts/run-headless.sh +++ b/scripts/run-headless.sh @@ -17,6 +17,10 @@ # custom one would otherwise inherit the other's output and quietly screenshot # the wrong size. # +# `--resize WxH@Hz` changes the output under the app once it is up, then +# screenshots. A resize is its own case: what it has to match is a cold start +# at that size, byte for byte, and nothing in `cargo test` can see it. +# # `--replay FILE` drives a `.touch` recording into the window through # `replay-touch`, which reads it with the same parser `iris::harness` uses. A # recording is ` down|move|up ` in the output's own pixels. With @@ -46,6 +50,7 @@ run="${XDG_RUNTIME_DIR:-/tmp}/iris-headless" seconds=3 shot="" replay="" +resize="" example="" kind=example mode=1920x1200@60Hz @@ -57,13 +62,14 @@ while [ $# -gt 0 ]; do --seconds) seconds=$2; shift 2 ;; --bin) kind=bin; shift ;; --mode) mode=$2; shift 2 ;; + --resize) resize=$2; shift 2 ;; --replay) replay=$2; shift 2 ;; --dir) workdir=$(cd "$2" && pwd); shift 2 ;; --) shift; break ;; *) example=$1; shift ;; esac done -[ -n "$example" ] || { echo "usage: $0 NAME [--bin] [--dir DIR] [--mode WxH@Hz] [--replay TOUCH] [--shot PNG] [--seconds N] [-- cargo args]" >&2; exit 2; } +[ -n "$example" ] || { echo "usage: $0 NAME [--bin] [--dir DIR] [--mode WxH@Hz] [--resize WxH@Hz] [--replay TOUCH] [--shot PNG] [--seconds N] [-- cargo args]" >&2; exit 2; } [ -z "$replay" ] || [ -f "$replay" ] || { echo "run-headless: no touch script at $replay" >&2; exit 2; } [ -z "$shot" ] || need grim "the screenshot --shot writes" @@ -142,6 +148,12 @@ while [ $i -lt "$((seconds * 2))" ]; do i=$((i + 1)); sleep 0.5 done +if [ -n "$resize" ] && kill -0 "$pid" 2>/dev/null; then + swaymsg output HEADLESS-1 mode "$resize" >/dev/null + echo "run-headless: resized to $resize" >&2 + sleep 2 +fi + if [ -n "$replay" ] && kill -0 "$pid" 2>/dev/null; then if [ -n "$shot" ]; then grim "${shot%.png}-before.png"