hex/packaging/macos/dmg/render.sh
Kit Langton 8184e51aed
macOS: lay out the installer window with Hex's keycap (#297)
* macOS: lay out the installer window with Hex's keycap (t423)

The DMG opens on a light window with Hex, an arrow to Applications, and Hex's own dark Option keycap beside "Hold it, say it, done." packaging/macos/dmg holds the background (1x and 2x TIFF), Finder's .DS_Store, and render.sh, which draws the keycap with Rune and regenerates both. scripts/notarize-app.sh lays out the local DMG with them; the Release workflow's DMG follows in a separate .github/ PR.

* Show the whole background: the window height includes its title bar

* Follow the hex rename; satisfy clippy
2026-10-28 12:03:13 -07:00

34 lines
1.6 KiB
Shell
Executable file
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/sh
set -eu
# Regenerates the installer window from background.html: Hex's keycap
# (src/rune_ui/dmg_keycap.rs, drawn with Rune), background.tiff (1× and 2×),
# and DS_Store (the Finder layout). Needs macOS, a Chromium-family browser
# (CHROME, else Google Chrome or Brave), and uv.
here=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
root=$(CDPATH= cd -- "$here/../../.." && pwd)
chrome=${CHROME:-}
for candidate in "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" \
"/Applications/Brave Browser.app/Contents/MacOS/Brave Browser"; do
[ -n "$chrome" ] || { [ -x "$candidate" ] && chrome=$candidate; }
done
[ -n "$chrome" ] || { echo "Set CHROME to a Chromium-family browser." >&2; exit 1; }
work=$(mktemp -d "${TMPDIR:-/tmp}/hex-dmg.XXXXXX")
trap 'hdiutil detach -quiet "$work/mnt" 2>/dev/null || true; rm -rf "$work"' EXIT HUP INT TERM
(cd "$root" && cargo test --locked --bin hex \
rune_ui::dmg_keycap::render -- --ignored --exact)
for scale in 1 2; do
"$chrome" --headless --disable-gpu --hide-scrollbars --user-data-dir="$work/profile" \
--force-device-scale-factor="$scale" --window-size=660,400 \
--screenshot="$work/background@${scale}x.png" "file://$here/background.html" 2>/dev/null
done
tiffutil -cathidpicheck "$work/background@1x.png" "$work/background@2x.png" \
-out "$here/background.tiff" >/dev/null 2>&1
mkdir "$work/Hex.app"
uv run --quiet --with dmgbuild==1.6.7 dmgbuild -s "$here/layout.py" \
-D app="$work/Hex.app" -D background="$here/background.tiff" Hex "$work/layout.dmg"
hdiutil attach -quiet -nobrowse -readonly -mountpoint "$work/mnt" "$work/layout.dmg"
cp "$work/mnt/.DS_Store" "$here/DS_Store"