diff options
| author | Craig Jennings <c@cjennings.net> | 2026-07-02 13:10:54 -0400 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-07-02 13:10:54 -0400 |
| commit | 67a609dd5e98df4df9a3fb40104817e0c25e5582 (patch) | |
| tree | 636b75b2e874b286e6e97db2f85f4bf1ea0fcd8b /scripts/theme-studio/screenshot-previews.sh | |
| parent | c3e183da48cc6c807b301a25c91fc0eaaec89a14 (diff) | |
| download | dotemacs-67a609dd5e98df4df9a3fb40104817e0c25e5582.tar.gz dotemacs-67a609dd5e98df4df9a3fb40104817e0c25e5582.zip | |
feat(theme-studio): screenshot harness + ecosystem coverage policy
Two speedrun-enabling pieces. A #preview=<app>&theme=<json> hash handler plus screenshot-previews.sh shoot any app's face table and live preview headlessly under a real theme (WIP.json by default), so preview work can be verified without a human clicking through the studio. The README gains the coverage policy: the studio themes popular packages even when uninstalled, pinning their faces rather than dropping them, and unloaded packages' previews matter more, not less.
Diffstat (limited to 'scripts/theme-studio/screenshot-previews.sh')
| -rwxr-xr-x | scripts/theme-studio/screenshot-previews.sh | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/scripts/theme-studio/screenshot-previews.sh b/scripts/theme-studio/screenshot-previews.sh new file mode 100755 index 00000000..72894aa7 --- /dev/null +++ b/scripts/theme-studio/screenshot-previews.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash +# Screenshot each theme-studio app's page (face table + live preview) headlessly. +# +# ./screenshot-previews.sh OUTDIR [APP ...] +# THEME=dupre.json ./screenshot-previews.sh OUTDIR [APP ...] +# +# With no APP arguments, shoots every app in the studio. Rides the #preview=<app> +# hash handler in app.js (the same hash-URL pattern as the browser gates), so the +# page selects the app itself before Chrome takes the shot. THEME names a theme +# JSON next to this script (default dupre.json; THEME= empty shoots untitled) so +# shots show real theme colors -- fresh headless profiles carry no localStorage. +# Regenerate the page first (make gen) when sources changed; this script shoots +# what is on disk. +set -uo pipefail + +HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +OUT="${1:?usage: screenshot-previews.sh OUTDIR [APP ...]}" +shift || true +mkdir -p "$OUT" + +BROWSER="" +for b in google-chrome-stable google-chrome chromium chromium-browser; do + command -v "$b" >/dev/null 2>&1 && { BROWSER="$b"; break; } +done +[ -n "$BROWSER" ] || { echo "no Chromium-family browser found" >&2; exit 1; } + +if [ "$#" -gt 0 ]; then + APPS="$*" +else + APPS="$(cd "$HERE" && python3 -c 'import generate; print(" ".join(sorted(generate.APPS)))')" +fi + +THEME="${THEME-WIP.json}" +SUFFIX="" +if [ -n "$THEME" ]; then + [ -f "$HERE/$THEME" ] || { echo "theme not found: $HERE/$THEME" >&2; exit 1; } + SUFFIX="&theme=$THEME" +fi + +for app in $APPS; do + "$BROWSER" --headless=new --disable-gpu --hide-scrollbars \ + --allow-file-access-from-files \ + --window-size=1500,2000 --virtual-time-budget=6000 \ + --screenshot="$OUT/$app.png" \ + "file://$HERE/theme-studio.html#preview=$app$SUFFIX" >/dev/null 2>&1 + if [ -s "$OUT/$app.png" ]; then + echo " shot $app" + else + echo " FAILED $app" >&2 + fi +done
\ No newline at end of file |
