scripts/gpui-shot.sh: ImageMagick 6 (convert, identify) where magick is not there

Debian and Ubuntu ship ImageMagick 6, which has no `magick`; the script now
uses `convert` and `identify` when `magick` is missing, and its header names
what it needs (xdotool, xwd, ImageMagick). Both branches were run on Xvfb
:98 (the second with a PATH that has `convert` and `identify` only): the
swatch picture is 1440x960 and the window closes with exit code 0.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
faumarayandClaude Sonnet 5.5 committed 2026-10-27 07:47:36 +03:00
1 parent 172d6247c6
commit d4f9e59ed6
1 file changed
+12 -2
+12 -2
View File
@@ -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