Skip to content

feat: register data sources behind one interface, including event-driven ones - #53

Merged
M4n0x merged 10 commits into
mainfrom
feat/data-sources
Oct 17, 2026
Merged

M4n0x merged 10 commits into
mainfrom
feat/data-sources

Conversation

@M4n0x

@M4n0x M4n0x commented Oct 17, 2026

Copy link
Copy Markdown
Collaborator

Problem

This implements #17's proposal. The issue's disk, nowPlaying and bluetooth providers are left for their own pull requests, so this one doesn't close it.

Built-in data sources were a fixed list, repeated across the code and the schema, and sampled on a timer. As a result:

  • a volume key press could take seconds to show;
  • power changes only reached profiles;
  • no source could say that it needs a permission.

Changes

  • Change-only output (perf). An unchanged script or provider output assigns nothing, so repeated updates redraw nothing.
  • Built-in events (refactor). One table lists each event's name and what INFO holds, and a test checks it against the README.
  • Data sources (refactor). Commands, streams and native readings run as data sources behind one runner, which keeps diagnostics, retry backoff and suspension.
  • Registry (feat).
    • Each source type registers its name, settings, events and permission in one table. Validation, Customize's add menu and the schema check read it.
    • Diagnostics and --query show each widget's source.
    • Main's calendar provider moved into the registry. Its settings, its output and its refresh when your calendar changes are unchanged, and Customize's add menu now offers Calendar.
  • Battery (feat). Battery widgets update when macOS reports a power change, without polling, and subscribed scripts get powerSourceChange (ac or battery).
  • Audio (feat). CoreAudio listeners update audio widgets as soon as the volume, the mute state or the default output device changes, and send volumeChange and outputDeviceChange. The modular example's volume script listens to volumeChange.
  • Setup permissions (feat). Setup lists the access that the data sources of enabled widgets need, with a link to its System Settings pane. Calendar is the first, with Calendars.

Testing

  • Suite. swift test passes 253 tests at the branch tip, 48 more than Draw every widget through layout blocks #16's branch: 43 for this issue and 5 for the calendar move. Every commit builds with its tests and passes the suite. No test requests a permission, touches the Keychain or reads a calendar.
  • Running bar, with a scratch configuration:
    • Volume. The audio widget and a subscribed script followed each change within about a second, with the volume in INFO, across a sweep of more than 50 changes.
    • Output device. Switching between a USB headset and the built-in speakers updated the widget, and outputDeviceChange carried the device name. When a device change and its volume change arrive together, a script can get only the later one; the README's rule for coalescing pending refreshes covers this.
    • Power. Unplugging and replugging sent battery, then ac, and the battery widget followed within 1 to 2 seconds.
    • Calendar. The Calendars prompt appeared with its explanation. Granting access refreshed the widget at once. Creating, moving and deleting an event each refreshed it within a second. Setup listed Calendars.
  • Not checked:
    • sleep and wake;
    • mute;
    • holding a volume key while the widget is disabled;
    • a volumeChange script with no audio widget while switching devices;
    • screenshots of the setup row and the add menu. The setup row was checked by eye.

Merging

This pull request builds on #16's branch. GitHub moves it to main when #16 merges and its branch is deleted.

Use a merge commit, so each commit reaches the changelog: five feat and one perf.

Claude Opus 5.5 via Claude Code

@M4n0x
M4n0x requested a review from Seb-GRAF as a code owner October 17, 2026 08:12
@M4n0x
M4n0x added this pull request to stack #54 October 17, 2026 08:24
Base automatically changed from feat/block-widgets to main October 17, 2026 08:24
@M4n0x
M4n0x force-pushed the feat/data-sources branch from 342a208 to 8e21d1d Compare October 17, 2026 08:24
@M4n0x
M4n0x merged commit 3e621ba into main Oct 17, 2026
4 checks passed
@M4n0x
M4n0x deleted the feat/data-sources branch October 17, 2026 08:27
@stablebar-releases

Copy link
Copy Markdown

🎉 This PR is included in version 0.5.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant