#!/usr/bin/env bash
# Status of the MIDI listener as one JSON line — polled by the node page's pill.
# Sees listeners started by ANYONE (this button, a terminal, the repo's
# SessionStart hook) because it matches on the binary path, not a job id.
HARNESS="$HOME/Documents/midi-harness"
PID=$(pgrep -f "$HARNESS/bin/listener" | head -1)
if [ -n "$PID" ]; then
  SINCE=$(ps -o lstart= -p "$PID" 2>/dev/null | sed 's/^ *//')
  echo "{\"running\":true,\"pid\":$PID,\"since\":\"$SINCE\"}"
else
  echo "{\"running\":false}"
fi
exit 0
