I am struggling to find some (elegant) way to connect my Mac to a (previously paired) Bluetooth device via terminal.
There is a solution using Applescript simulating mouse clicks, but it has some major issues:
- Bluetooth menu needs to be visible in the Menu bar
- Terminal needs access to the Accessibility Controls
- Does not work reliably
- It is slow as hell
- When you use the mouse while the script is running, it fails.
So, this is more or less a no-go..
I don't need to switch Bluetooth on and off in general, I don't need any pairing mechanism, I just need some way to trigger the connection to known devices via terminal.
My use case is a Bluetooth Sound Module - for example I called it "NoiseBox". What I want is this:
./magic-script.sh connect NoiseBox
./magic-script.sh disconnect NoiseBox
Can you help me?
PS: Is it possible to write some small Application in Swift or ObjC which does this?