SPB Git

Repository Public

shot.sh 1.5 KB 25 lines shellscript

1#!/usr/bin/env bash2# ORIX Sonata3# File: Scripts/shot.sh4# Description: Launches a silent instance (no audio device) on one space, waits, captures its window by window id, then quits it. Never activates the app or touches the mouse and keyboard.5#   Scripts/shot.sh <out.png> <space> [dark|light] [seconds] [document path] [extra app arguments…]6#   SONATA_APP=<path>  app bundle to launch (default: the Debug build)7#8# Author: Simon-Pierre Boucher9# Contact: contact@spboucher.ai10set -euo pipefail11cd "$(dirname "$0")/.."12OUT="$1"; SPACE="${2:-code}"; APPEARANCE="${3:-dark}"; WAIT="${4:-6}"; DOC="${5:-}"; shift $(( $# < 5 ? $# : 5 ))13APP="${SONATA_APP:-build/DerivedData/Build/Products/Debug/ORIX Sonata.app}"14[[ -x build/tools/winid ]] || { mkdir -p build/tools; swiftc -O Scripts/tools/winid.swift -o build/tools/winid; }15ARGS=(-SonataNoAudio YES -SonataSpace "$SPACE" -SonataAppearance "$APPEARANCE" -AppleLanguages "(${SONATA_LANG:-en})" -AppleLocale "${SONATA_LOCALE:-en_US}" -ApplePersistenceIgnoreState YES -NSQuitAlwaysKeepsWindows NO)16if [[ -n "$DOC" ]]; then "$APP/Contents/MacOS/ORIX Sonata" "${ARGS[@]}" "$@" "$DOC" >/dev/null 2>&1 & else "$APP/Contents/MacOS/ORIX Sonata" "${ARGS[@]}" "$@" >/dev/null 2>&1 & fi17PID=$!18trap 'kill $PID 2>/dev/null || true' EXIT19sleep "$WAIT"20ID="$(build/tools/winid "$PID" | head -1 | cut -d' ' -f1)"21[[ -n "$ID" ]] || { echo "no window for pid $PID" >&2; exit 1; }22mkdir -p "$(dirname "$OUT")"23screencapture -x -o -l "$ID" "$OUT"24echo "$OUT ($(sips -g pixelWidth -g pixelHeight "$OUT" | awk '/pixel/{printf "%s ", $2}'))"25
Files main
Menu

Theme