dev/screenshots: the tooling for the README screenshots
take.sh builds arr-tui, starts a fake Radarr, Sonarr and SABnzbd with a made-up library (catalog.py, server.py, generated posters), and runs the scene scripts in Ghostty under Xvfb, writing docs/screenshots/. Run on the same day it reproduces the committed pictures byte for byte. make test also shellchecks the scripts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019reK4DUGYqDUjniWYJvwUW
This commit is contained in:
Executable
+36
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env bash
|
||||
# Run a command in Ghostty on a virtual X display and follow a scene script.
|
||||
#
|
||||
# xshot.sh <scene> <outdir> "<extra ghostty args>" <command...>
|
||||
#
|
||||
# Scene lines: key <keysyms...> | type <text> | sleep <seconds> | shot <name>
|
||||
# (shot saves the Ghostty window as <outdir>/<name>.png).
|
||||
set -euo pipefail
|
||||
scene=$1 out=$2 extra=$3
|
||||
shift 3
|
||||
export GDK_BACKEND=x11 LIBGL_ALWAYS_SOFTWARE=1 GSK_RENDERER=gl
|
||||
unset WAYLAND_DISPLAY DBUS_SESSION_BUS_ADDRESS
|
||||
|
||||
# shellcheck disable=SC2016 # expanded by the inner shell
|
||||
xvfb-run -a -s "-screen 0 1800x1200x24" bash -c '
|
||||
scene=$1 out=$2 extra=$3
|
||||
shift 3
|
||||
# shellcheck disable=SC2086 # extra holds several arguments
|
||||
ghostty --gtk-single-instance=false --class=arrshot --window-width=132 --window-height=38 \
|
||||
--window-decoration=false --confirm-close-surface=false --font-size=12 \
|
||||
--window-padding-x=8 --window-padding-y=6 $extra -e "$@" >/dev/null 2>&1 &
|
||||
ghostty=$!
|
||||
sleep 7 # Ghostty with software rendering takes a while to show its window
|
||||
wid=$(xdotool search --onlyvisible --pid "$ghostty" | tail -n1)
|
||||
while read -r cmd args; do
|
||||
case $cmd in
|
||||
key) for k in $args; do xdotool key "$k"; sleep 0.25; done ;;
|
||||
type) xdotool type --delay 80 "$args"; sleep 0.5 ;;
|
||||
sleep) sleep "$args" ;;
|
||||
shot) import -window "$wid" "$out/$args.png" ;;
|
||||
""|"#"*) ;;
|
||||
*) echo "unknown scene command: $cmd" >&2; exit 1 ;;
|
||||
esac
|
||||
done < "$scene"
|
||||
kill "$ghostty" 2>/dev/null || true
|
||||
' _ "$scene" "$out" "$extra" "$@"
|
||||
Reference in New Issue
Block a user