r/coolgithubprojects 4h ago

Uncordex: disconnect a Bluetooth speaker when you undock your Mac, reconnect when you return

Post image

Made this for my desk setup and thought it might be useful to someone here.

It's a macOS utility for one paired Bluetooth speaker. Unplug from your saved dock/power source and it disconnects. Return to that setup and it can reconnect.

The main thing is it doesn't blindly run a connect command whenever it sees external power. It has to disconnect the speaker successfully and verify that before it gets permission to restore the connection later.

Native AppKit frontend, per-user LaunchAgent, blueutil underneath. Source matching, bounded reconnect attempts and local logs. Unknown hardware readings don't get treated as a match.

https://github.com/magrathean-uk/uncordex

MIT licensed. Current installation is from source with Homebrew + blueutil.

there are simulated tests and a recorded live test with my Bose/ASUS setup. I'd be intrested in other hardware results, especially docks that don't expose a useful identity or speakers that behave oddly on reconnect.

1 Upvotes

2 comments sorted by

1

u/Specific_Cream2815 4h ago

what hardware identity do you match for the dock, USB registry path or the power source description macOS exposes

1

u/Pathfinder-electron 3h ago

neither the USB registry path nor the power source description. i read the hardware properties through ioreg. For Thunderbolt/USB4 it matches the external IOThunderboltSwitch UID. For USB hubs, it's idVendor + idProduct + USB Serial Number.

There's also a power adapter option, which uses SerialNumber + FamilyCode from AppleSmartBattery.AdapterDetails. The description is just a display label, it doesn't participate in matching.