blob: 72894aa7f0e3e56f2f854f8b41feda2d1de43e9e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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
|