← All repositories

listless

A simple list app for Apple platforms

git clone https://code.inqk.net/listless.git


Scripts/screenshots-ipad.sh (3400B)

1#!/bin/bash
2set -euo pipefail
3
4DO_COMPOSE=false
5while getopts "c" opt; do
6  case $opt in
7    c) DO_COMPOSE=true ;;
8    *) ;;
9  esac
10done
11shift $((OPTIND - 1))
12
13MAJOR="${1:-26}"
14RUNTIME=$(xcrun simctl list runtimes available \
15  | grep "iOS ${MAJOR}\." \
16  | sed 's/.*iOS \([0-9.]*\).*/\1/' \
17  | sort -t. -k1,1n -k2,2n \
18  | tail -1)
19
20if [ -z "$RUNTIME" ]; then
21  echo "No available iOS ${MAJOR}.x simulator runtime found." >&2
22  exit 1
23fi
24
25# Prefer iPad Pro 13" for ASC screenshots (2064x2752)
26DEVICE=$(xcrun simctl list devices available "iOS ${RUNTIME}" \
27  | grep "iPad Pro 13" \
28  | head -1 \
29  | sed 's/^ *\(.*\) ([A-F0-9-]*).*/\1/')
30if [ -z "$DEVICE" ]; then
31  DEVICE=$(xcrun simctl list devices available "iOS ${RUNTIME}" \
32    | grep "iPad" \
33    | head -1 \
34    | sed 's/^ *\(.*\) ([A-F0-9-]*).*/\1/')
35fi
36
37if [ -z "$DEVICE" ]; then
38  echo "No available iPad simulator found for iOS ${RUNTIME}." >&2
39  exit 1
40fi
41
42echo "Using ${DEVICE}, iOS ${RUNTIME}"
43
44# Boot simulator if needed
45UDID=$(xcrun simctl list devices available "iOS ${RUNTIME}" \
46  | grep "$DEVICE" \
47  | head -1 \
48  | sed 's/.*(\([A-F0-9-]*\)).*/\1/')
49
50xcrun simctl boot "$UDID" 2>/dev/null || true
51
52# Override status bar: 9:41, full signal, full battery
53xcrun simctl status_bar "$UDID" override \
54  --time "9:41" \
55  --batteryState discharging \
56  --batteryLevel 100 \
57  --wifiBars 3 \
58  --cellularBars 4 \
59  --cellularMode active \
60  --dataNetwork wifi
61
62echo "Status bar overridden"
63
64SCREENSHOT_TMP="/tmp/listless-screenshots"
65FRAMED_TMP="/tmp/listless-framed"
66MARKETING_DIR="$(pwd)/Marketing"
67SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
68
69# iPad Pro 13" ASC canvas dimensions
70CANVAS_WIDTH=2064
71CANVAS_HEIGHT=2752
72
73CAPTIONS=(
74  "Syncs via iCloud"
75  "Minimalist"
76  "Gesture Based"
77  "(Slightly) Customisable"
78)
79
80# Run screenshot tests (same iOS UI test target, different simulator)
81xcodebuild test \
82  -scheme "Listless iOS" \
83  -destination "platform=iOS Simulator,name=${DEVICE},OS=${RUNTIME}" \
84  -only-testing:"Listless iOS UI Tests/ListlessiOSScreenshots" \
85  2>&1
86
87# Clear status bar override (ignore errors if simulator already shut down)
88xcrun simctl status_bar "$UDID" clear 2>/dev/null || true
89
90if ! ls "${SCREENSHOT_TMP}"/*.png 1>/dev/null 2>&1; then
91  echo "No screenshots found in ${SCREENSHOT_TMP}."
92  exit 1
93fi
94
95mkdir -p "${MARKETING_DIR}"
96
97if [ "$DO_COMPOSE" = true ]; then
98  mkdir -p "${FRAMED_TMP}"
99
100  echo ""
101  echo "Framing screenshots..."
102  n=0
103  for file in "${SCREENSHOT_TMP}"/0*.png; do
104    shortcuts run "Frame Screenshots" -i "$file" -o "${FRAMED_TMP}/framed_${n}.png"
105    echo "  Framed screenshot ${n}"
106    n=$((n + 1))
107  done
108
109  echo "Composing final images..."
110  n=0
111  for file in "${FRAMED_TMP}"/framed_*.png; do
112    caption="${CAPTIONS[$n]:-}"
113    swift "${SCRIPT_DIR}/screenshots-ios-compose.swift" "$file" "${MARKETING_DIR}/ipad_${n}.png" "$caption" "$CANVAS_WIDTH" "$CANVAS_HEIGHT"
114    echo "  ipad_${n}.png — ${caption}"
115    n=$((n + 1))
116  done
117
118  rm -rf "${FRAMED_TMP}"
119else
120  OUTPUT_DIR="$(pwd)"
121  echo ""
122  n=0
123  for file in "${SCREENSHOT_TMP}"/0*.png; do
124    cp "$file" "${OUTPUT_DIR}/ipad_${n}.png"
125    n=$((n + 1))
126  done
127fi
128
129rm -rf "${SCREENSHOT_TMP}"
130
131if [ "$DO_COMPOSE" = true ]; then
132  echo ""
133  echo "Screenshots saved to ${MARKETING_DIR}/"
134  ls -la "${MARKETING_DIR}"/ipad_*.png
135else
136  echo ""
137  echo "Screenshots saved to ${OUTPUT_DIR}/"
138  ls -la "${OUTPUT_DIR}"/ipad_*.png
139fi