Branchwell

Graphley / app · graphley.ai / design / app-store / capture.sh

Raw 1.5 KB on d69ca9c4c8ff088be085e80dbb7478e9463bddf8
1#!/bin/zsh
2# capture.sh <udid> <outdir> <demo workspace folder | connect>
3# With a folder (from make-demo-workspace.py): launches Graphley on those fictional numbers as if synced from a Mac
4# and screenshots every screen the debug shot tour shows. With "connect": screenshots the connect-to-your-Mac screen.
5udid=$1; out=$2; source=${3:?pass a demo workspace folder or connect}
6app=${GRAPHLEY_SIM_APP:?set GRAPHLEY_SIM_APP to a Debug simulator Graphley.app}
7[[ $source == connect ]] || rm -rf "$out"; mkdir -p "$out" # connect adds to the same folder
8xcrun simctl terminate $udid com.protomota.graphley 2>/dev/null
9xcrun simctl install $udid $app
10xcrun simctl status_bar $udid override --time "9:41" --batteryState charged --batteryLevel 100 --wifiBars 3 --cellularBars 4 --dataNetwork wifi
11if [[ $source == connect ]]; then
12 SIMCTL_CHILD_GRAPHLEY_DEMO_CONNECT=1 SIMCTL_CHILD_GRAPHLEY_SHOT_DIR="$out" xcrun simctl launch $udid com.protomota.graphley >/dev/null
13else
14 SIMCTL_CHILD_GRAPHLEY_DEMO_WORKSPACE="${source:A}" SIMCTL_CHILD_GRAPHLEY_SHOT_DIR="$out" xcrun simctl launch $udid com.protomota.graphley >/dev/null
15fi
16done_names=()
17for i in {1..400}; do
18 for f in "$out"/*.ready(N); do
19 name=${f:t:r}
20 [[ $name == finished ]] && { rm -f "$f"; echo "captured ${#done_names} screens"; exit 0; }
21 if (( ! ${done_names[(Ie)$name]} )); then
22 xcrun simctl io $udid screenshot "$out/$name.png" >/dev/null 2>&1
23 done_names+=$name; rm -f "$f"
24 fi
25 done
26 sleep 0.3
27done
28echo "timed out"; exit 1