Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lapfelix/bluetoothconnector
Simple macOS CLI to connect/disconnect a Bluetooth device. Useful for AirPods or other Bluetooth headphones.
https://github.com/lapfelix/bluetoothconnector
airpods automator-workflow beats beatsx bluetooth macos macos-cli shortcut swift swift-package swift-package-manager
Last synced: 15 days ago
JSON representation
Simple macOS CLI to connect/disconnect a Bluetooth device. Useful for AirPods or other Bluetooth headphones.
- Host: GitHub
- URL: https://github.com/lapfelix/bluetoothconnector
- Owner: lapfelix
- License: mit
- Created: 2017-02-14T04:49:13.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-04-09T12:52:17.000Z (7 months ago)
- Last Synced: 2024-04-26T06:04:23.926Z (7 months ago)
- Topics: airpods, automator-workflow, beats, beatsx, bluetooth, macos, macos-cli, shortcut, swift, swift-package, swift-package-manager
- Language: Swift
- Homepage:
- Size: 113 KB
- Stars: 522
- Watchers: 10
- Forks: 34
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# BluetoothConnector [![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Flapfelix%2FBluetoothConnector%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/lapfelix/BluetoothConnector)
Simple macOS CLI to connect/disconnect a Bluetooth device. I made it to easily connect my BeatsX earbuds (I thought the W1 chip would make the switch from my iPhone to my Mac seamless, but we're not there yet, apparently). There's probably a program that already does this but I didn't find it.You can download a compiled version here: https://github.com/lapfelix/BluetoothConnector/releases
If you have issues running the compiled binary (`permission denied` error), try running this command in Terminal:
`chmod +x /path/to/BluetoothConnector`# Installation
### [Homebrew](https://brew.sh)
```
brew install bluetoothconnector
```### [Mint](https://github.com/yonaskolb/Mint)
```
mint install lapfelix/BluetoothConnector
```### Manually
```
swift package update
swift build -c release
mv .build/release/BluetoothConnector /usr/local/bin/BluetoothConnector
```# Usage
#### Running
Replace `00-00-00-00-00-00` with your device's MAC address. You can get it by alt-clicking the Bluetooth menu icon or by running BluetoothConnector without any arguments##### To toggle the connection (connect/disconnect) and be notified about it
```
BluetoothConnector 00-00-00-00-00-00 --notify
```##### To connect and be notified about it
```
BluetoothConnector --connect 00-00-00-00-00-00 --notify
BluetoothConnector -c 00-00-00-00-00-00 --notify
```##### To disconnect
```
BluetoothConnector --disconnect 00-00-00-00-00-00
BluetoothConnector -d 00-00-00-00-00-00
```##### Notification Center
You can have BluetoothConnector send a notification to say what it did (connect or disconnect), if the action succeeded or get an error description if something goes wrong
```
BluetoothConnector 00-00-00-00-00-00 --notify
```To reduce Notification Center pollution, I'd recommend turning off "Show in Notification Center" for the Script Editor app in the Notifications system preferences:
#### With Automator to bind a shortcut to it (this is how I'm using it)
I included an Automator workflow service that calls BluetoothConnector from `/usr/local/bin` to make it easier to run BluetoothConnector with a keyboard workflow (this is how I'm using it).Then open the Automator workflow and you should get a prompt to install it (don't forget to change the MAC address).
To bind a shortcut to the Automator service, launch System Preferences and Go to `Keyboard > Shortcuts > Services`, find your service and add a shortcut to it.