#!/bin/bash # Install (or refresh) the login agent that keeps the Resi -> ProPresenter bridge running. # Double-click this file. Safe to run again after a git pull. set -euo pipefail HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SOURCE="$HERE/resi_to_propresenter.py" LABEL="org.waterschurch.resi-propresenter" PLIST="$HOME/Library/LaunchAgents/$LABEL.plist" CONFIG_DIR="$HOME/Library/Application Support/ResiCues" LOG="$HOME/Library/Logs/resi-propresenter.log" [ -f "$SOURCE" ] || { echo "Cannot find $SOURCE"; exit 1; } mkdir -p "$HOME/Library/LaunchAgents" "$CONFIG_DIR" "$(dirname "$LOG")" # A login agent cannot read ~/Documents (and ~/Desktop, ~/Downloads) without Full Disk # Access — macOS answers "Operation not permitted". Rather than ask for that, run from # a copy in Application Support, which is not gated. Re-run this after a git pull. SCRIPT="$CONFIG_DIR/resi_to_propresenter.py" cp "$SOURCE" "$SCRIPT" if [ ! -f "$CONFIG_DIR/config.json" ]; then cp "$HERE/config.example.json" "$CONFIG_DIR/config.json" echo "Made a starter config at $CONFIG_DIR/config.json — set resi_user and player in it." fi cat > "$PLIST" < Label$LABEL ProgramArguments /usr/bin/python3 $SCRIPT EnvironmentVariables RESI_PP_CONFIG$CONFIG_DIR/config.json WorkingDirectory$CONFIG_DIR RunAtLoad KeepAlive ThrottleInterval30 ProcessTypeBackground StandardOutPath$LOG StandardErrorPath$LOG PLIST_EOF launchctl bootout "gui/$UID/$LABEL" 2>/dev/null || true launchctl bootstrap "gui/$UID" "$PLIST" launchctl enable "gui/$UID/$LABEL" 2>/dev/null || true echo echo "Installed. It starts at login and restarts itself if it stops." echo " script $SCRIPT (a copy — re-run this after a git pull)" echo " config $CONFIG_DIR/config.json" echo " log $LOG" echo echo "Watch it with: tail -f \"$LOG\"" echo "Stop it with: launchctl bootout gui/$UID/$LABEL" echo "Start it again: launchctl bootstrap gui/$UID \"$PLIST\""