Summary
Add a --watch flag to meshd status --json that streams newline-delimited JSON on state change instead of a one-shot output.
Motivation
The current --json flag works for one-shot scripts but Quickshell widgets need to poll on a timer, which is janky and wastes CPU. A --watch mode would make widgets fully reactive with zero overhead — they just read stdin.
Proposed Behavior
meshd status --json --watch
# streams a new JSON line every time state changes (device connects, file syncs, conflict detected, etc.)
# powered by /rest/events?since=<n> under the hood
Output format (newline-delimited JSON):
{"devices":[{"name":"MacBook","status":"online","completion":100}],"syncing":false,"conflicts":0}
{"devices":[{"name":"MacBook","status":"syncing","completion":73}],"syncing":true,"conflicts":0}
Implementation Notes
- Subscribe to
/rest/events?since=<n> (long-poll, already used by the TUI)
- On each relevant event, re-fetch
/rest/db/status and emit a new JSON line to stdout
- Relevant event types:
StateChanged, DeviceConnected, DeviceDisconnected, FolderCompletion, LocalChangeDetected
- Exits cleanly on
ctrl+c / SIGTERM
Use Cases
- Quickshell / EWW / Waybar widgets that show sync status in a bar
- Shell scripts that wait for sync to complete before proceeding
- Agent workflows polling for file propagation confirmation
Summary
Add a
--watchflag tomeshd status --jsonthat streams newline-delimited JSON on state change instead of a one-shot output.Motivation
The current
--jsonflag works for one-shot scripts but Quickshell widgets need to poll on a timer, which is janky and wastes CPU. A--watchmode would make widgets fully reactive with zero overhead — they just read stdin.Proposed Behavior
Output format (newline-delimited JSON):
{"devices":[{"name":"MacBook","status":"online","completion":100}],"syncing":false,"conflicts":0} {"devices":[{"name":"MacBook","status":"syncing","completion":73}],"syncing":true,"conflicts":0}Implementation Notes
/rest/events?since=<n>(long-poll, already used by the TUI)/rest/db/statusand emit a new JSON line to stdoutStateChanged,DeviceConnected,DeviceDisconnected,FolderCompletion,LocalChangeDetectedctrl+c/ SIGTERMUse Cases