Detect the rig's binaries, and take the machine out of its comments

The comments described the machine the rig was written on -- "this
machine has no display", "there is a real GPU here", an Android
emulator's GLX quirk -- which says nothing to anyone reading it from a
different checkout. What the reader needs is what the script supplies
and why, which is now all they get.

`sway`, `swaymsg` and, when `--shot` is passed, `grim` are checked up
front and named in the failure, rather than surfacing as a compositor
that would not start.

The `# shellcheck disable=SC2086 -- prose` directive did not parse, so
the suppression was not in effect; the prose moves to its own line.
Clean under shellcheck now.
This commit is contained in:
iris-ai committed 2026-09-14 00:36:19 -04:00
1 parent 9d13f15bee
commit deb9c1b6d7
2 files changed
+23 -14

No files matched your search

+7 -7
View File
@@ -1,13 +1,13 @@
# The compositor `scripts/run-headless.sh` starts, because this machine has no # The compositor `scripts/run-headless.sh` starts, so that an example has a
# display. Nothing here is meant to be looked at directly; `grim` is. # surface where there is no display. Nothing here is meant to be looked at
# directly; `grim` is.
# #
# No Xwayland: winit talks Wayland natively, and starting an X server is a # No Xwayland: winit talks Wayland natively, so an X server is a second thing
# second thing to go wrong for no gain. (`emu`'s config forces it because the # to go wrong for no gain.
# Android emulator's renderer speaks GLX.)
xwayland disable xwayland disable
# A desktop-shaped output, since this is the desktop half of the port. Larger # The default output, overridden per run by `--mode`. Larger than the window
# than the window an example opens, so nothing is scaled or clipped. # an example opens, so nothing is scaled or clipped.
output HEADLESS-1 mode 1920x1200@60Hz output HEADLESS-1 mode 1920x1200@60Hz
default_border none default_border none
+16 -7
View File
@@ -23,13 +23,21 @@
# `--shot` it also writes `<shot>-before.png` from just before the gesture, # `--shot` it also writes `<shot>-before.png` from just before the gesture,
# since "it moved" is a claim about two pictures. # since "it moved" is a claim about two pictures.
# #
# There is a real GPU here and no display, so what is missing is only a # What it supplies is a compositor for winit to open a surface on: a headless
# compositor to give winit a surface: a headless sway, and `grim` to see the # sway, and `grim` to screenshot it. Sway gets its own socket and runtime
# result. It has its own socket and runtime directory rather than joining # directory rather than joining whatever else is running, because it tiles --
# whatever else is running, because sway tiles -- adding a window to someone # adding a window to someone else's compositor resizes theirs.
# else's compositor resizes theirs.
set -eu set -eu
need() {
command -v "$1" >/dev/null 2>&1 || {
echo "run-headless: $1 is not installed ($2)" >&2
exit 127
}
}
need sway "the compositor an example opens its window on"
need swaymsg "sway's control socket"
scripts=$(cd "$(dirname "$0")" && pwd) scripts=$(cd "$(dirname "$0")" && pwd)
root=$(cd "$scripts/.." && pwd) root=$(cd "$scripts/.." && pwd)
workdir="$root" workdir="$root"
@@ -57,6 +65,7 @@ while [ $# -gt 0 ]; do
done 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] [--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 "$replay" ] || [ -f "$replay" ] || { echo "run-headless: no touch script at $replay" >&2; exit 2; }
[ -z "$shot" ] || need grim "the screenshot --shot writes"
mkdir -p "$run" mkdir -p "$run"
export SWAYSOCK="$run/sway.sock" export SWAYSOCK="$run/sway.sock"
@@ -110,8 +119,8 @@ else
bin="$workdir/target/debug/examples/$example" bin="$workdir/target/debug/examples/$example"
fi fi
# shellcheck disable=SC2086 -- deliberately word-split: this is the # Deliberately word-split: this is the binary's own argv, not a single path.
# binary's own argv, not a single path. # shellcheck disable=SC2086
"$bin" ${RUN_HEADLESS_ARGS:-} >"$run/$example.log" 2>&1 & "$bin" ${RUN_HEADLESS_ARGS:-} >"$run/$example.log" 2>&1 &
pid=$! pid=$!
trap 'kill "$pid" 2>/dev/null || true' EXIT INT TERM trap 'kill "$pid" 2>/dev/null || true' EXIT INT TERM