Repository Public License
1#!/usr/bin/env bash2# ORIX Clean — Scripts/shot.sh3# Description: Launches an isolated instance on the sample home folder and captures its window (by window id).4# Scripts/shot.sh <out.png> <section> [dark|light] [extra app args…]5# Author: Simon-Pierre Boucher — contact@spboucher.ai6set -euo pipefail7cd "$(dirname "$0")/.."8OUT="$1"; SECTION="$2"; LOOK="${3:-dark}"; shift 3 || shift $#9APP="${ORIX_APP:-build/DerivedData/Build/Products/Debug/ORIX Clean.app}"10HOME_DIR="${ORIX_DEMO_HOME:-/tmp/orix-demo/home}"11WAIT="${ORIX_WAIT:-5}"12"$APP/Contents/MacOS/ORIX Clean" -ORIXHome "$HOME_DIR" -ORIXStore "${ORIX_STORE:-memory}" -ORIXScanRoot "$HOME_DIR" -ORIXSection "$SECTION" \13 -ORIXAppearance "$LOOK" -ORIXSkipOnboarding YES -ORIXAutoAnalyze YES -ApplePersistenceIgnoreState YES "$@" >/dev/null 2>&1 &14PID=$!15sleep "$WAIT"16WID=$(swift - "$PID" <<'SWIFT'17import CoreGraphics18import Foundation19let pid = Int32(CommandLine.arguments[1])!20let list = CGWindowListCopyWindowInfo([.optionOnScreenOnly, .excludeDesktopElements], kCGNullWindowID) as? [[String: Any]] ?? []21if ProcessInfo.processInfo.environment["ORIX_FRONT"] != nil {22 // Frontmost window of the instance (a sheet or the Settings window); the list is ordered front to back.23 for w in list where (w[kCGWindowOwnerPID as String] as? Int32) == pid && (w[kCGWindowLayer as String] as? Int) == 0 {24 print(w[kCGWindowNumber as String] as? Int ?? 0); exit(0)25 }26}27var best = (0, 0.0)28for w in list where (w[kCGWindowOwnerPID as String] as? Int32) == pid && (w[kCGWindowLayer as String] as? Int) == 0 {29 let b = w[kCGWindowBounds as String] as? [String: Double] ?? [:]30 let area = (b["Width"] ?? 0) * (b["Height"] ?? 0)31 if area > best.1 { best = (w[kCGWindowNumber as String] as? Int ?? 0, area) }32}33print(best.0)34SWIFT35)36if [[ -n "${ORIX_HOOK:-}" ]]; then eval "$ORIX_HOOK"; fi37mkdir -p "$(dirname "$OUT")"38screencapture -x -o -l "$WID" "$OUT"39kill "$PID" 2>/dev/null || true40wait "$PID" 2>/dev/null || true41echo "$OUT"42