diff --git a/scripts/gpui-shot.sh b/scripts/gpui-shot.sh index e164ede..89d5505 100755 --- a/scripts/gpui-shot.sh +++ b/scripts/gpui-shot.sh @@ -12,6 +12,8 @@ # GPUI_SHOT_HEADLESS=1 spikes/gpui/shell.sh spikes/gpui/headless.sh -- \ # scripts/gpui-shot.sh docs/ui/gpui-swatch-dark.png swatch 1440x960 # +# Needs xdotool, xwd (x11-apps) and ImageMagick. +# # Wayland is taken out of the environment (GPUI prefers it, so the window # would open on the desktop), and so are the desktop's session bus and its # portals; the app's state and the XDG directories are a temporary one. @@ -39,6 +41,14 @@ if [ "${GPUI_SHOT_HEADLESS:-}" != 1 ]; then GPUI_SHOT_HEADLESS=1 exec xvfb-run -a -s "-screen 0 $((w * 2))x$((h * 2))x24" "$0" "$@" fi [ -n "${DISPLAY:-}" ] || { echo "gpui-shot.sh: no DISPLAY" >&2; exit 2; } +# ImageMagick 7 has `magick`; the 6 of Debian and Ubuntu has `convert` and `identify`. +if command -v magick >/dev/null 2>&1; then + to_png() { magick xwd:- "png:$1"; } + size_of() { magick identify -format '%wx%h' "$1"; } +else + to_png() { convert xwd:- "png:$1"; } + size_of() { identify -format '%wx%h' "$1"; } +fi root=$(cd "$(dirname "$0")/.." && pwd) bin=${VOELIN_BIN:-} if [ -z "$bin" ]; then @@ -67,8 +77,8 @@ until win=$(xdotool search --name '^Voelin$' 2>/dev/null | head -1) && [ -n "$wi sleep 0.1 done sleep "${DELAY:-4}" -xwd -id "$win" -silent | magick xwd:- "png:$out" -echo "$out: $(magick identify -format '%wx%h' "$out")" +xwd -id "$win" -silent | to_png "$out" +echo "$out: $(size_of "$out")" # Close it as a user does; with no window manager, ask the process to end. xdotool windowactivate --sync "$win" 2>/dev/null || true xdotool key alt+F4 2>/dev/null || true