Skip to content

Send events when displays, active profiles or popups change #302

Closed as duplicate

Description

@M4n0x

Problem

Scripts can subscribe to eight built-in events (BuiltInEvents.swift:4-5) and to distributed notifications. Three changes that StableBar already handles inside aren't sent to them:

  • Displays. Connecting, disconnecting or rearranging displays rebuilds the bars in screensChanged (StableBarApp.swift:282-291), but a script that shows something per display, or changes when the Mac docks, only finds out on its next poll. SketchyBar sends display_change, and yabai display_added and display_removed.
  • Active profiles. They change with the appearance, power source, displays and front app, and --query lists them, but no event is sent, so a script that behaves differently per profile has to poll.
  • Popups. A widget whose popup lists something slow to fetch, such as open pull requests, polls to keep the popup current, even when nobody opens it. SwiftBar's refreshOnOpen refreshes a plugin as its menu opens.

Proposal

  • displayChange: sent after the bars are rebuilt for a new set of displays. INFO is the number of displays.
  • profileChange: sent when the active profiles change. INFO is a JSON array of their names.
  • popupOpen and popupClose: INFO is the widget's ID, so a widget's script can refresh when its own popup opens.
  • The table under Script events in docs/create-a-widget.md lists them; builtInEventsMatchTheGuideTable checks it.
  • Open question: should a widget subscribed to popupOpen hear only its own popup, so other popups don't run its script?

Possible today

No for profiles and popups. For displays, a polling script can compare system_profiler SPDisplaysDataType output.

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

    same events as #299, keeping them there so scripts and --subscribe get them from one place

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