hydra

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

hydra.sh (2076B)


      1 #!/usr/bin/env bash
      2 # hydra.sh — SketchyBar plugin showing Hydra's live routing state.
      3 #
      4 # Install: see scripts/sketchybar/README.md. Reads state via `hydra query --sketchybar`
      5 # (one serde contract with the daemon — no fragile socket parsing in shell).
      6 #
      7 # Colors come from $CONFIG_DIR/theme.sh if present (export ACCENT/GHOST/FG_DIM/DANGER as
      8 # 0xAARRGGBB) — point that at your own palette. Otherwise neutral defaults below are used.
      9 
     10 HYDRA_BIN="${HYDRA_BIN:-$HOME/Library/CloudStorage/Dropbox/Projects/Apps/hydra/target/release/hydra}"
     11 [ -x "$HYDRA_BIN" ] || HYDRA_BIN="$HOME/Library/CloudStorage/Dropbox/Projects/Apps/hydra/target/debug/hydra"
     12 
     13 # Neutral fallback colors (0xAARRGGBB), matching Hydra's built-in default theme.
     14 ACCENT=0xffe09b3e      # amber
     15 GHOST=0xff4cc2b0       # teal highlight
     16 FG_DIM=0xff8a9099      # muted grey
     17 DANGER=0xffe06c6c      # red
     18 [ -f "$CONFIG_DIR/theme.sh" ] && source "$CONFIG_DIR/theme.sh" 2>/dev/null || true
     19 
     20 # Pull state. Each line is key=value; tolerate the daemon being down.
     21 state="down"; routes=0; active=0; peak=0; label="hydra"
     22 if out="$("$HYDRA_BIN" query --sketchybar 2>/dev/null)"; then
     23     while IFS='=' read -r k v; do
     24         case "$k" in
     25             state) state="$v" ;;
     26             routes) routes="$v" ;;
     27             active) active="$v" ;;
     28             peak) peak="$v" ;;
     29             label) label="$v" ;;
     30         esac
     31     done <<< "$out"
     32 fi
     33 
     34 # Choose icon + colors by state. Glyphs are Nerd Font (match your bar's font).
     35 case "$state" in
     36     down)
     37         icon="󰜺"; icon_color=$FG_DIM; label="hydra off"; label_color=$FG_DIM ;;
     38     idle)
     39         icon="󰓃"; icon_color=$FG_DIM; label="idle"; label_color=$FG_DIM ;;
     40     active)
     41         icon="󰓃"; icon_color=$ACCENT
     42         # Clip warning if any route is hot.
     43         if awk "BEGIN{exit !($peak > 0.9)}" 2>/dev/null; then
     44             label_color=$DANGER
     45         else
     46             label_color=$GHOST
     47         fi
     48         ;;
     49 esac
     50 
     51 sketchybar --set "$NAME" \
     52     icon="$icon" icon.color="$icon_color" \
     53     label="$label" label.color="$label_color" \
     54     drawing=on