hydra

Terminal replacement for Loopback — virtual audio devices and routing on macOS, from a ratatui TUI.
Log | Files | Refs | README | LICENSE

install-agent.sh (1650B)


      1 #!/usr/bin/env bash
      2 # install-agent.sh — run hydrad as a per-user LaunchAgent (GUI session).
      3 #
      4 # The daemon MUST run in the user's GUI login session, not as a system LaunchDaemon:
      5 # process taps and their TCC consent are bound to that session. RunAtLoad + KeepAlive
      6 # keep routing alive across logins and restarts.
      7 #
      8 # Run ./scripts/bundle.sh first so dist/Hydra.app exists.
      9 set -euo pipefail
     10 
     11 ROOT="$(cd "$(dirname "$0")/.." && pwd)"
     12 APP="$ROOT/dist/Hydra.app"
     13 EXEC="$APP/Contents/MacOS/hydrad"
     14 LABEL="com.ganten.hydrad"
     15 PLIST="$HOME/Library/LaunchAgents/$LABEL.plist"
     16 
     17 if [ ! -x "$EXEC" ]; then
     18     echo "error: $EXEC not found — run ./scripts/bundle.sh first." >&2
     19     exit 1
     20 fi
     21 
     22 echo "• writing $PLIST"
     23 mkdir -p "$HOME/Library/LaunchAgents"
     24 cat > "$PLIST" <<PLIST_EOF
     25 <?xml version="1.0" encoding="UTF-8"?>
     26 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
     27 <plist version="1.0">
     28 <dict>
     29     <key>Label</key>
     30     <string>$LABEL</string>
     31     <key>ProgramArguments</key>
     32     <array>
     33         <string>$EXEC</string>
     34     </array>
     35     <key>RunAtLoad</key>
     36     <true/>
     37     <key>KeepAlive</key>
     38     <true/>
     39     <key>StandardErrorPath</key>
     40     <string>/tmp/hydrad.err.log</string>
     41     <key>StandardOutPath</key>
     42     <string>/tmp/hydrad.out.log</string>
     43 </dict>
     44 </plist>
     45 PLIST_EOF
     46 
     47 echo "• (re)loading agent"
     48 launchctl bootout "gui/$(id -u)/$LABEL" 2>/dev/null || true
     49 launchctl bootstrap "gui/$(id -u)" "$PLIST"
     50 launchctl kickstart -k "gui/$(id -u)/$LABEL"
     51 
     52 echo "✓ $LABEL loaded. Logs: /tmp/hydrad.err.log"
     53 echo "  First time you start a route, macOS will prompt for Audio Recording access."