Repository Public
1#!/usr/bin/env bash2# Author: Simon-Pierre Boucher — contact@spboucher.ai3# File: Scripts/shot.sh4# Description: Captures the window of the Debug build of SP Notes to a PNG (visual checks during development); never a window of the installed application.5# Usage: Scripts/shot.sh out.png6set -euo pipefail7cd "$(dirname "$0")/.."8[[ -x build/window-shot && build/window-shot -nt Scripts/window-shot.swift ]] || swiftc -O Scripts/window-shot.swift -o build/window-shot 2>/dev/null9# only the Debug build's process: the installed application's windows are never captured10PID=""11for pid in $(pgrep -x "SP Notes" 2>/dev/null || true); do12 case "$(ps -o command= -p "$pid" 2>/dev/null)" in *"/Products/Debug/SP Notes.app/Contents/MacOS/"*) PID="$pid" ;; esac13done14[[ -n "$PID" ]] || { echo "no Debug instance of SP Notes is running" >&2; exit 1; }15build/window-shot "SP Notes" "$1" "$PID" | tail -116