Files
proxy-suite-flake/windows/tools/gui-shot.sh
T
faumarayandClaude Opus 5.5 4ae30dac3c windows: ps-client shared by proxy-ctl and the app; the app's first window
- ps-client: the service's client side, moved out of proxy-ctl: calls,
  configuration edits against the revision read (retried on a concurrent
  change), log following, and the edits themselves as functions on the
  configuration (outbounds, subscriptions, rules, zapret, tg-ws-proxy),
  now unit-tested. proxy-ctl does what it did, through it; a refused log
  follow is now an error instead of nothing.
- ps-gui: proxy-suite, the desktop app on GPUI (gpui-kit 0.8.1); only a
  first window yet. Not in default-members: plain cargo build/test and the
  release workflow's tests leave GPUI out.
- tools/gui-shot.sh: runs the app on Xvfb with Mesa's software Vulkan and
  screenshots it, to check the GUI on Linux without a display.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 01:13:28 +03:00

39 lines
1.6 KiB
Bash
Executable File

#!/usr/bin/env bash
# The app without a display: run on Xvfb with Mesa's software Vulkan (lavapipe), and a
# screenshot of it once it has drawn. For checking the GUI on Linux, in the dev shell.
#
# tools/gui-shot.sh OUT.png [SECONDS] [-- APP ARGS...] (APP=target/debug/proxy-suite)
#
# With SHOT_KEYS="key ..." the keys (xdotool names) are typed into the window before the shot.
set -euo pipefail
OUT=$(realpath -m "${1:?the screenshot, a .png}"); shift
WAIT=6
if [ $# -gt 0 ] && [ "$1" != "--" ]; then WAIT=$1; shift; fi
[ "${1:-}" = "--" ] && shift
cd "$(dirname "$0")/.."
APP=$(realpath "${APP:-target/debug/proxy-suite}")
GEOMETRY=${GEOMETRY:-1280x820}
path() { nix build --no-link --print-out-paths --inputs-from . "nixpkgs#$1.out" | head -1; }
XVFB=$(path xvfb) MESA=$(path mesa) MAGICK=$(path imagemagick) XDOTOOL=$(path xdotool)
n=90
while [ -e "/tmp/.X11-unix/X$n" ] || [ -e "/tmp/.X$n-lock" ]; do n=$((n + 1)); done
"$XVFB/bin/Xvfb" ":$n" -screen 0 "${GEOMETRY}x24" -nolisten tcp >/dev/null 2>&1 &
XPID=$!
trap 'kill "${APID:-}" "$XPID" 2>/dev/null || true' EXIT
for _ in $(seq 50); do [ -e "/tmp/.X11-unix/X$n" ] && break; sleep 0.1; done
env -u WAYLAND_DISPLAY DISPLAY=":$n" VK_ICD_FILENAMES="$MESA/share/vulkan/icd.d/lvp_icd.x86_64.json" \
"$APP" "$@" >"${OUT%.png}.log" 2>&1 &
APID=$!
sleep "$WAIT"
kill -0 "$APID" 2>/dev/null || { echo "the app exited:"; tail -20 "${OUT%.png}.log"; exit 1; }
if [ -n "${SHOT_KEYS:-}" ]; then
# shellcheck disable=SC2086
DISPLAY=":$n" "$XDOTOOL/bin/xdotool" key --delay 150 $SHOT_KEYS
sleep 1.5
fi
DISPLAY=":$n" "$MAGICK/bin/magick" import -window root "$OUT"
echo "$OUT"