Skip to content

Follow the bar's events and state from the command line #299

Closed as not planned

Description

@M4n0x

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-initial skips 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 as frontApp and workspace, configuration (reloaded, or failed with its error) and sessionEdits.
  • StableBar --wait EVENT [--timeout SECONDS] exits 0 at the first matching event, and with another status on timeout. A ready event, sent once a bar has loaded its configuration, lets StableBar --config "$scratch/config.json" --wait ready replace a sleep after launching a bar.
  • With --config they follow that configuration. --subscribe ends 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 CFMessagePort with 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

Triaged by Claude Code (Claude Opus 5.5).

Activity

  1. added
    enhancement
    on Oct 23, 2026
  2. added
    P3
    on Nov 8, 2026
  3. Seb-GRAF commented on Nov 11, 2026

    @Seb-GRAF
    Collaborator

    also covers #302: send displayChange, profileChange, popupOpen and popupClose to widget scripts too, not only to --subscribe

  4. Seb-GRAF commented on Nov 11, 2026

    @Seb-GRAF
    Collaborator

    nobody needs a live event stream yet, --query is enough for now. same for the script events from #302

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions