SPB Git

Repository Public

shot.sh 1.9 KB 31 lines shellscript

1#!/usr/bin/env bash2# ORIX DJ3# File: Scripts/shot.sh4# Description: Launches an isolated, silent instance on one section, waits, captures its window by PID, then quits it.5#   Scripts/shot.sh <out.png> <section> [dark|light] [seconds] [extra app arguments…]6#   ORIX_APP=<path>    app bundle to launch (default: build/dd Debug build)7#   ORIX_DATA=<dir>    data directory to reuse (default: a fresh temporary one)8#   ORIX_WINDOW=<text> capture the window whose title contains the text (default: the largest window)9#   ORIX_FRAME="x y w h 0 0 sw sh"  window frame (default 1440 x 900)10#   The instance renders audio in real time without opening an audio device (-ORIXSilent YES): nothing is played aloud.11#12# Author: Simon-Pierre Boucher13# Contact: contact@spboucher.ai14set -euo pipefail15cd "$(dirname "$0")/.."16OUT="$1"; SECTION="$2"; APPEARANCE="${3:-dark}"; WAIT="${4:-8}"; shift $(( $# < 4 ? $# : 4 ))17APP="${ORIX_APP:-build/dd/Build/Products/Debug/ORIX DJ.app}"18DATA="${ORIX_DATA:-$(mktemp -d /tmp/orixdj-shot.XXXXXX)}"19[[ -x build/tools/winid ]] || { mkdir -p build/tools; swiftc -O Scripts/tools/winid.swift -o build/tools/winid; }20"$APP/Contents/MacOS/ORIX DJ" -ORIXDataDir "$DATA" -ORIXSilent YES -ORIXDemo YES -ORIXSection "$SECTION" -ORIXAppearance "$APPEARANCE" \21  -AppleLanguages "(${ORIX_LANG:-en})" -AppleLocale "${ORIX_LOCALE:-en_US}" \22  -NSWindow\ Frame\ main "${ORIX_FRAME:-80 80 1440 900 0 0 3456 2234}" -ApplePersistenceIgnoreState YES "$@" >/dev/null 2>&1 &23PID=$!24trap 'kill $PID 2>/dev/null || true' EXIT25sleep "$WAIT"26if [[ -n "${ORIX_WINDOW:-}" ]]; then ID="$(build/tools/winid "$PID" | grep -i -- "$ORIX_WINDOW" | head -1 | cut -d' ' -f1)"; else ID="$(build/tools/winid "$PID" | head -1 | cut -d' ' -f1)"; fi27[[ -n "$ID" ]] || { echo "no window for pid $PID" >&2; exit 1; }28mkdir -p "$(dirname "$OUT")"29screencapture -x -o -l "$ID" "$OUT"30echo "$OUT ($(sips -g pixelWidth -g pixelHeight "$OUT" | awk '/pixel/{printf "%s ", $2}'))"31
Files main
Menu

Theme