SPB Git

Repository Public License

shot.sh 3.4 KB 67 lines shellscript

1#!/usr/bin/env bash2# =============================================================================3#                  SP BOUCHER | INFRASTRUCTURE & AUTOMATION4#             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5# =============================================================================6#7# Project          : ORIX Monitor8# File             : Scripts/shot.sh9# Description      : Launches an isolated instance on one section, waits for10#                    real samples, captures its window by PID, then quits it.11#                    Scripts/shot.sh <out.png> <section> [dark|light] [seconds]12#                    [extra app arguments…] ORIX_APP=<path> app bundle to13#                    launch (default: Debug build) ORIX_DATA=<dir> data14#                    directory to reuse (default: a fresh temporary one)15#                    ORIX_LANG / ORIX_LOCALE interface language and number16#                    formats (default: en / en_US, whatever the Mac is set to)17# Module           : Scripts18# Repository       : https://git.spboucher.ai/orix-monitor19# Created          : 2026-11-2120# Last Modified    : 2026-11-2121#22# Author           : Simon-Pierre Boucher23# Position         : Professor of Finance24# Institution      : Université du Québec en Outaouais (UQO)25# Organization     : SP Boucher26# Website          : https://spboucher.ai27# Git              : https://git.spboucher.ai28#29# Preferred Contact: support@spboucher.ai30# Technical Contact: dev@spboucher.ai31# Security/Admin   : admin@spboucher.ai32#33# Copyright (c) 202634# Simon-Pierre Boucher35# All rights reserved where applicable. This file is governed by the36# applicable project license, copyright notices and relevant law.37# Existing third-party rights and notices remain unaffected.38#39# License          : Proprietary, all rights reserved (see license file)40# License File     : LICENSE41#42# Do not embed credentials, private keys, access tokens,43# certificates or confidential personal information.44#45# =============================================================================46# END OF SP BOUCHER SOURCE HEADER47# =============================================================================4849set -euo pipefail50cd "$(dirname "$0")/.."51OUT="$1"; SECTION="$2"; APPEARANCE="${3:-dark}"; WAIT="${4:-14}"; shift $(( $# < 4 ? $# : 4 ))52APP="${ORIX_APP:-build/dd/Build/Products/Debug/ORIX Monitor.app}"53DATA="${ORIX_DATA:-$(mktemp -d /tmp/orix-shot.XXXXXX)}"54[[ -x build/tools/winid ]] || { mkdir -p build/tools; swiftc -O Scripts/tools/winid.swift -o build/tools/winid; }55"$APP/Contents/MacOS/ORIX Monitor" -ORIXUITest YES -ORIXDataDir "$DATA" -ORIXSection "$SECTION" -ORIXAppearance "$APPEARANCE" -ORIXPrivacy YES \56  -AppleLanguages "(${ORIX_LANG:-en})" -AppleLocale "${ORIX_LOCALE:-en_US}" \57  -NSWindow\ Frame\ main "${ORIX_FRAME:-120 120 1360 900 0 0 3456 2234}" -ApplePersistenceIgnoreState YES "$@" >/dev/null 2>&1 &58PID=$!59trap 'kill $PID 2>/dev/null || true' EXIT60sleep "$WAIT"61# ORIX_WINDOW=<title fragment> captures a specific window (e.g. the Settings window) instead of the largest one.62if [[ -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)"; fi63[[ -n "$ID" ]] || { echo "no window for pid $PID" >&2; exit 1; }64mkdir -p "$(dirname "$OUT")"65screencapture -x -o -l "$ID" "$OUT"66echo "$OUT ($(sips -g pixelWidth -g pixelHeight "$OUT" | awk '/pixel/{printf "%s ", $2}'))"67
Files main
Menu

Theme