#!/bin/sh
# Toggle Blurt recording by signaling the running tray app directly.
#
# A direct SIGUSR1 avoids the ~0.5s cost of "uv run blurt toggle", which
# imported the full numpy/scipy/sounddevice/pystray stack just to send one
# signal. The PID file is written by blurt.py's setup_toggle_trigger().

PID_FILE="${TMPDIR:-/tmp}/blurt.pid"

pid=$(cat "$PID_FILE" 2>/dev/null)
if [ -n "$pid" ] && kill -USR1 "$pid" 2>/dev/null; then
    exit 0
fi

notify-send blurt "Blurt is not running" 2>/dev/null
exit 1
