Repository navigation
Description
Problem
Other tools can send the bar commands, but nothing tells them what the bar does. A script that should react when the active profiles change, a popup opens or a widget enters critical has to poll StableBar --query, which returns the whole composed configuration each time. Scripts and tests that start a bar and wait for it to load sleep a fixed time.
StableBar consumes this kind of stream itself: workspace widgets run aerospace subscribe (Workspaces.swift:206). AeroSpace (aerospace subscribe), sway (swaymsg -t subscribe), Hyprland's event socket and SwayNC (swaync-client -s) offer one, and bars and scripts built around them depend on it.
Proposal
StableBar --subscribe [EVENT ...]keeps running and prints one JSON object per line. The first line is the current state: active profiles, the open popup, each widget's data state and the configuration error (--no-initialskips it). Each event follows as it happens. Without names, it prints every event.- Events:
profiles(the active profiles changed),popup(opened or closed, with the widget ID),state(a widget's data state changed),trigger(an event sent to the bar, with its data), the built-in events such asfrontAppandworkspace,configuration(reloaded, or failed with its error) andsessionEdits. StableBar --wait EVENT [--timeout SECONDS]exits 0 at the first matching event, and with another status on timeout. Areadyevent, sent once a bar has loaded its configuration, letsStableBar --config "$scratch/config.json" --wait readyreplace a sleep after launching a bar.- With
--configthey follow that configuration.--subscribeends with a distinct status when the bar quits. - Events carry IDs, names and states, not widget text, which can be private.
- Open question: the transport. The control endpoint is a request/reply
CFMessagePortwith a 10-second reply timeout (RuntimeControl.swift:57-70). Distributed notifications reach every process of the user; a port that the subscriber registers with the bar keeps events to it.
Possible today
Partly. A script widget can subscribe to built-in and triggered events and forward them somewhere, but changes of profiles, popups, data states and the configuration aren't events, so --query has to be polled.
Related
- Let commands set conditions that profiles match, such as the current Focus #81 adds context values that profiles match;
profilesevents would report the result. - Set a widget's content from the command line without a script #298 sets widget content from outside; this one reports what the bar does.
Triaged by Claude Code (Claude Opus 5.5).
Activity
Seb-GRAF commentedon Nov 11, 2026
also covers #302: send
displayChange,profileChange,popupOpenandpopupCloseto widget scripts too, not only to--subscribeSeb-GRAF commentedon Nov 11, 2026
nobody needs a live event stream yet,
--queryis enough for now. same for the script events from #302