Repository navigation
Description
Scope, as narrowed in the comments below: a bluetooth provider that reads system_profiler SPBluetoothDataType -json and needs no permission, with lists.devices (name, kind, icon, battery, level, fraction), fields.summary, values.lowestBattery and text. Power, addresses, connect and disconnect events, and Bluetooth access stay out: they need IOBluetooth and its access prompt.
Problem
The bar can't show which Bluetooth devices are connected or how charged they are. You learn that a Magic Mouse or AirPods are low only when macOS warns you. Stats, iStat Menus and Waybar's bluetooth module show both. The battery provider covers only the Mac's own battery.
Proposal
- A
bluetoothprovider:fields.power(onoroff),fields.connected(the number of connected devices), andlists.deviceswithname,address,kind(such asheadphones,mouse,keyboard,trackpad) andbatterywhen the device reports one.values.lowestBattery(0–1) letsruleswarn when any device runs low. - It updates on connect and disconnect notifications and polls battery levels every
interval, and sendsbluetoothChangeandbluetoothDeviceChangeevents. - Its registry entry declares Bluetooth access, so setup lists it, and
Info.plistgainsNSBluetoothAlwaysUsageDescription. Packages can already declare"permissions": ["bluetooth"]; no store package uses it yet. - Connecting or disconnecting a device from a popup row is a possible follow-up.
APIs, and what I could and couldn't verify:
- Connected devices:
IOBluetoothDevice.pairedDevices()withisConnected(), andIOBluetoothDevice.register(forConnectNotifications:selector:), are public in IOBluetooth. On recent macOS, apps using IOBluetooth need Bluetooth access; I didn't verify whether reading paired devices alone prompts. - Magic Mouse, Keyboard and Trackpad battery: the
BatteryPercentproperty on their HID services in the IORegistry, read with public IOKit calls (IOServiceGetMatchingServices,IORegistryEntryCreateCFProperty). No access needed, as far as I know. - AirPods and other headphones: per-bud and case levels aren't in a public API. They're in private
IOBluetoothDevicemethods (such asbatteryPercentLeft), which conflicts with the public-API stance, and insystem_profiler SPBluetoothDataTypeoutput, which is slow to run. Open question: show headphone battery only where a public source exists, or leave it to packages.
Possible today
Partly. A script can parse system_profiler SPBluetoothDataType -json for connected devices and AirPods battery, and ioreg -r -k BatteryPercent for Magic accessories. system_profiler takes about a second each run, and nothing tells the script when a device connects.
Related
- Register data sources behind one interface, including event-driven ones #17 listed a
bluetoothprovider among the sources its registry would enable; feat: register data sources behind one interface, including event-driven ones #53 left it for its own pull request. - Add a Wi-Fi provider with the network name and signal strength #69 (Wi-Fi) is the same kind of request for another radio.
Sources/StableBar/WidgetPackage.swiftalready accepts thebluetoothpackage permission.
Triaged by Claude Code via T3 Code (Claude Opus 5.5).
Activity
Seb-GRAF commentedon Nov 11, 2026
needs Bluetooth access, and AirPods battery is private API. not worth it for now
Seb-GRAF commentedon Nov 16, 2026
reopening for the part that needs no permission: an
accessoriesprovider that lists Apple keyboards, mice and trackpads with their battery, read fromBatteryPercenton their HID services with public IOKit. No IOBluetooth, so no Bluetooth accesslists.deviceswithname,kind(keyboard,mouse,trackpad) andbatteryas a whole percentagevalues.lowestBattery(0–1) sorulescan warn when one runs lowintervalAirPods and other headphones stay out, their battery is only in private API. A script can still read them from
system_profiler SPBluetoothDataType. The fullbluetoothprovider above stays a follow-upSeb-GRAF commentedon Nov 16, 2026
changing the approach: Apple's
BatteryPercentonly covers Magic accessories, and most keyboards and mice people use (and AirPods) don't publish it.system_profiler SPBluetoothDataType -jsonlists every connected device with the battery macOS knows, AirPods per bud included, without any permission, and answers in about 0.1 s hereso the provider becomes
bluetooth, reading that output natively so packages can use it:lists.deviceswithname,kind(keyboard,mouse,trackpad,headphones,other),icon,battery(such as100%or76% · 77%) andlevel(the lowest, as a whole percentage)fields.summary, the devices with a battery in one line,values.lowestBattery, andtextthe number of connected devicesinterval, off the main threadit's the first native provider that runs a tool instead of calling an API, so DECISIONS.md gets an entry for it. Its JSON keys aren't documented by Apple, so a missing key just leaves that device's battery empty
stablebar-releases commentedon Nov 16, 2026
🎉 This issue has been resolved in version 0.17.0 🎉
The release is available on GitHub release
Your semantic-release bot 📦🚀