← All repositories

reportage

A life-logging app for iPhone

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


Scripts/screenshots-iphone.sh (1827B)

1#!/bin/bash
2# Takes a screenshot of the timeline with the demo reports, on the demo
3# simulator, with the status bar set to 9:41 and full signal and battery.
4# Draws the Dynamic Island over it, since the simulator leaves it out; -n
5# skips that.
6#
7# Usage: bash Scripts/screenshots-iphone.sh [-n] [-o output.png] [iOS-major]
8#        (default output Marketing/iphone_0.png, default major 27)
9set -euo pipefail
10
11SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
12REPO_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)"
13source "${SCRIPT_DIR}/demo-simulator.sh"
14
15ADD_DYNAMIC_ISLAND=true
16OUTPUT_PATH="${REPO_DIR}/Marketing/iphone_0.png"
17while getopts "no:" opt; do
18  case $opt in
19    n) ADD_DYNAMIC_ISLAND=false ;;
20    o) OUTPUT_PATH="$OPTARG" ;;
21    *) exit 1 ;;
22  esac
23done
24shift $((OPTIND - 1))
25
26SCREENSHOT_TMP="/tmp/reportage-screenshot.png"
27rm -f "$SCREENSHOT_TMP"
28
29demo_simulator "${1:-27}"
30xcrun simctl ui "$UDID" appearance light
31xcrun simctl status_bar "$UDID" override \
32  --time "9:41" \
33  --batteryState discharging \
34  --batteryLevel 100 \
35  --wifiBars 3 \
36  --cellularBars 4 \
37  --cellularMode active \
38  --dataNetwork wifi
39echo "Status bar overridden"
40
41demo_install
42demo_launch
43
44# Time for the seed to fill the store and the timeline to draw it.
45sleep 4
46
47xcrun simctl io "$UDID" screenshot --mask ignored "$SCREENSHOT_TMP"
48xcrun simctl status_bar "$UDID" clear 2>/dev/null || true
49
50if [ ! -f "$SCREENSHOT_TMP" ]; then
51  echo "Screenshot capture failed." >&2
52  exit 1
53fi
54
55mkdir -p "$(dirname "$OUTPUT_PATH")"
56echo ""
57if [ "$ADD_DYNAMIC_ISLAND" = true ]; then
58  echo "Adding Dynamic Island..."
59  swift "${SCRIPT_DIR}/screenshots-iphone-island.swift" "$SCREENSHOT_TMP" "$OUTPUT_PATH"
60else
61  echo "Skipping Dynamic Island..."
62  cp "$SCREENSHOT_TMP" "$OUTPUT_PATH"
63fi
64
65echo ""
66echo "Screenshot saved to ${OUTPUT_PATH}"
67ls -la "$OUTPUT_PATH"