install.sh (2304B)
1 #!/usr/bin/env bash 2 # install.sh — one-command Hydra setup. 3 # 4 # Builds and installs everything in the right order, pausing before the steps that 5 # need sudo or restart audio so nothing happens behind your back: 6 # 7 # 1. build the Rust workspace (release) 8 # 2. build + sign Hydra.app (the daemon, with the audio-capture entitlement) 9 # 3. load the daemon as a per-user LaunchAgent (routing persists across logins) 10 # 4. build + install the Hydra virtual-audio driver ← sudo + ~1s audio glitch 11 # 12 # After this, "Hydra" is selectable as an input device in other apps, and the `hydra` 13 # TUI drives routing. Re-run any time; it's idempotent. 14 # 15 # Usage: 16 # ./install.sh # full install (prompts before the sudo driver step) 17 # ./install.sh --no-driver # everything except the driver (capture→speakers only) 18 set -euo pipefail 19 20 ROOT="$(cd "$(dirname "$0")" && pwd)" 21 WITH_DRIVER=1 22 [ "${1:-}" = "--no-driver" ] && WITH_DRIVER=0 23 24 say() { printf '\n\033[1;36m▸ %s\033[0m\n' "$1"; } 25 26 say "1/4 Building the Rust workspace (release)" 27 cargo build --manifest-path "$ROOT/Cargo.toml" --release --workspace 28 29 say "2/4 Building + signing Hydra.app" 30 "$ROOT/scripts/bundle.sh" release 31 32 say "3/4 Loading the daemon as a LaunchAgent" 33 "$ROOT/scripts/install-agent.sh" 34 35 # Install a `hydra` launcher on PATH for convenience (best-effort). 36 if [ -w /usr/local/bin ] || sudo -n true 2>/dev/null; then 37 say "Installing the 'hydra' command to /usr/local/bin" 38 sudo ln -sf "$ROOT/target/release/hydra" /usr/local/bin/hydra 2>/dev/null \ 39 || ln -sf "$ROOT/target/release/hydra" /usr/local/bin/hydra 2>/dev/null \ 40 || echo " (skipped — add $ROOT/target/release to PATH yourself)" 41 fi 42 43 if [ "$WITH_DRIVER" = "1" ]; then 44 say "4/4 Building the Hydra virtual-audio driver" 45 "$ROOT/scripts/build-driver.sh" 46 say "Installing the driver (needs sudo; restarts coreaudiod, ~1s audio glitch)" 47 "$ROOT/scripts/install-driver.sh" 48 else 49 say "4/4 Skipped driver install (--no-driver). Run ./scripts/install-driver.sh later." 50 fi 51 52 cat <<DONE 53 54 ✓ Hydra installed. 55 56 Launch the control panel: hydra (or: cargo run -p hydra) 57 In another app, pick "Hydra" as the microphone/input to receive routed audio. 58 59 Daemon logs: /tmp/hydrad.err.log 60 Uninstall: ./uninstall.sh 61 DONE