I am trying to connect and pair a Bluetooth device from the command line. I can do it over the GUI using the standard process but I am looking to automate the whole process.
I am looking for commands that can be executed in a shell script to connect to the Bluetooth device. Just like Linux has "hcitool", "pand" commands, I am trying to find equivalent commands for macOS.
How can I accomplish this?
Best Answer
blueutil
(available via HomeBrew) is the answer. I just used it following the guidelines in this blog post.In my case, I had an iMac with macOS Catalina that had no trackpad paired. I was stuck at the "Send Apple Crash Analytics?" screen with no keyboard controls. Using SSH, I connected to the machine and used the following commands to pair and then connect the trackpad without access to the GUI. (First, I had to turn the trackpad into Discoverable mode. The default PIN for Apple pointer devices is
0000
.)At that point, the trackpad worked.