hydra

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

install-driver.sh (2220B)


      1 #!/usr/bin/env bash
      2 # install-driver.sh — install the Hydra HAL driver. REQUIRES sudo and RESTARTS coreaudiod
      3 # (all audio glitches for ~1s). Run this yourself; the daemon never does it silently.
      4 #
      5 #   ./scripts/build-driver.sh        # first, produce driver/build/Hydra.driver
      6 #   ./scripts/install-driver.sh      # then install (will prompt for sudo)
      7 set -euo pipefail
      8 
      9 ROOT="$(cd "$(dirname "$0")/.." && pwd)"
     10 DRIVER="$ROOT/driver/build/Hydra.driver"
     11 HAL="/Library/Audio/Plug-Ins/HAL"
     12 MANIFEST_DIR="/Library/Application Support/hydra"
     13 
     14 if [ ! -d "$DRIVER" ]; then
     15     echo "error: $DRIVER not found — run ./scripts/build-driver.sh first." >&2
     16     exit 1
     17 fi
     18 
     19 echo "This installs a system audio driver and restarts coreaudiod (~1s audio dropout)."
     20 echo "  driver:   $DRIVER"
     21 echo "  dest:     $HAL/Hydra.driver"
     22 echo "  manifest: $MANIFEST_DIR/devices.json (world-readable; coreaudiod reads it)"
     23 read -r -p "Continue? [y/N] " ans
     24 case "$ans" in [yY]|[yY][eE][sS]) ;; *) echo "aborted."; exit 0 ;; esac
     25 
     26 echo "• installing driver"
     27 sudo rm -rf "$HAL/Hydra.driver"
     28 sudo cp -R "$DRIVER" "$HAL/Hydra.driver"
     29 
     30 echo "• creating manifest dir (you write it, coreaudiod reads it)"
     31 # Two readers with different identities:
     32 #   - the Hydra daemon runs as YOU and writes devices.json (device name) → needs write
     33 #   - coreaudiod runs as _coreaudiod and reads it at driver load → needs world-read
     34 # admin-group-owned + group-writable + world-readable satisfies both without 777.
     35 sudo mkdir -p "$MANIFEST_DIR"
     36 sudo chgrp admin "$MANIFEST_DIR"
     37 sudo chmod 775 "$MANIFEST_DIR"
     38 # If a manifest already exists, make it group-writable too so renames can overwrite it.
     39 [ -f "$MANIFEST_DIR/devices.json" ] && sudo chmod 664 "$MANIFEST_DIR/devices.json" || true
     40 
     41 echo "• restarting coreaudiod"
     42 # SIP blocks `launchctl kickstart` of coreaudiod ("Operation not permitted while SIP is
     43 # engaged"). Killing it is allowed — launchd respawns it immediately.
     44 sudo killall coreaudiod 2>/dev/null || true
     45 
     46 sleep 2
     47 echo
     48 echo "✓ installed. Verify:"
     49 echo "    system_profiler SPAudioDataType | grep -i hydra"
     50 echo "  or in the Hydra TUI's device list."
     51 echo
     52 echo "Uninstall: sudo rm -rf \"$HAL/Hydra.driver\" && sudo killall coreaudiod"