Repository navigation
Description
Problem
The built-in data sources are a fixed list, repeated in several places: ProviderType (Sources/StableBar/ProviderConfiguration.swift:3), the NativeMetrics.sample switch (Sources/StableBar/NativeMetrics.swift:55), ScriptWidget.Source (Sources/StableBar/ScriptWidget.swift:79) and the type checks in Sources/StableBar/Configuration.swift:289 and :377. Adding a source means changing all of them and the schema.
Built-in sources are also only sampled on a timer (ScriptWidget.swift:158), every 5 s by default. Sources that macOS pushes don't fit:
- The audio provider reads the default output device on each poll (
NativeMetrics.swift:158) instead of listening for volume, mute and device changes, so a volume key press can take seconds to show. - Power-source changes are already observed, but only to match profiles (
Sources/StableBar/SystemContext.swift:27). - EventKit change notifications and Bluetooth connections have nowhere to go.
No source can declare that it needs a permission (Calendars, Bluetooth, Automation), so setup can't ask before a widget fails.
Built-in events are wired one at a time in BarStore (Sources/StableBar/BarStore.swift:48, :54, :73, :220), alongside configuration loading, process lifecycle and actions. Scripts get no event for volume or power changes.
Proposal
- A
DataSourceprotocol that pushes output:start(emit:),refresh(event:),stop(). Polling becomes an adapter, andcommandandstreambecome sources as well.ScriptWidgetstays the generic runner: diagnostics, retry backoff, suspension. - A registry entry for each source: its type name, settings decoder (also used by the schema), required permission, and the events it emits. Configuration validation reads from the registry.
- One table of built-in events, giving each name and what
INFOholds, and checked against the README the way the schema is checked against the decoders. Push sources add events such asvolumeChange,outputDeviceChangeandpowerSourceChange. - Setup lists the permissions that enabled sources need.
This would unlock:
- Audio through CoreAudio listeners: immediate volume, mute and device changes, plus a
volumeChangeevent - Battery updates when the power source changes
- A
diskprovider (used and free space of a volume) - A
nowPlayingprovider (Spotify and Music distributed notifications, artwork URL) - A
bluetoothprovider (connected devices) - The calendar provider, Add a calendar provider for the next meeting and today's agenda #18
Possible today
Partly. A stream provider can push updates, for example a helper that prints a line whenever the output device changes. Each such source needs its own helper process, and built-in providers can't be made event-driven.
Related
#6 (yabai) adds a workspace source beside AeroSpace, and its events could use the same table.
Triaged by Claude Code (Claude Opus 5.5).
Activity
M4n0x commentedon Oct 15, 2026
Performance
Push sources should reduce work, since audio would no longer be polled every 5 s, as long as bursts are coalesced. Holding a volume key fires a stream of CoreAudio notifications, and a calendar sync can post
EKEventStoreChangedmany times in a row.Requirements for this change:
AsyncStreamwith.bufferingNewest(1),Sources/StableBar/ScriptWidget.swift:117), so a burst collapses to its newest value.ScriptOutputto beEquatable.whenVisible, sleep), the way polling stops today.Triaged by Claude Code (Claude Opus 5.5).