简单的 macOS 命令行工具,用于连接/断开蓝牙设备。我制作它是为了方便连接我的 BeatsX 耳机(我以为 W1 芯片能让从 iPhone 切换到 Mac 变得无缝,但显然我们还没达到那种程度)。可能已经有程序可以做到这一点,但我没有找到。
您可以在这里下载编译好的版本: https://github.com/lapfelix/BluetoothConnector/releases
如果您在运行编译好的二进制文件时遇到问题(permission denied
错误),请尝试在终端中运行此命令:chmod +x /path/to/BluetoothConnector
brew install bluetoothconnector
mint install lapfelix/BluetoothConnector
swift package update
swift build -c release
mv .build/release/BluetoothConnector /usr/local/bin/BluetoothConnector
将 00-00-00-00-00-00
替换为您的设备的 MAC 地址。您可以通过按住 Alt 键并点击蓝牙菜单图标来获取它,或者直接运行不带任何参数的 BluetoothConnector
BluetoothConnector 00-00-00-00-00-00 --notify
BluetoothConnector --connect 00-00-00-00-00-00 --notify
BluetoothConnector -c 00-00-00-00-00-00 --notify
BluetoothConnector --disconnect 00-00-00-00-00-00
BluetoothConnector -d 00-00-00-00-00-00
您可以让 BluetoothConnector 发送通知,告知您它执行的操作(连接或断开连接),操作是否成功,或者在出现问题时获取错误描述。
BluetoothConnector 00-00-00-00-00-00 --notify
为了减少通知中心的消息干扰,我建议在“通知”系统偏好设置中关闭“在通知中心显示”Script Editor 应用的通知。
我包含了一个 Automator 工作流程服务,它从 /usr/local/bin
调用 BluetoothConnector,以便更轻松地使用键盘快捷流程运行 BluetoothConnector(我就是这样用的)。
然后打开 Automator 工作流程,您应该会收到安装提示(不要忘记更改 MAC 地址)。要将快捷键绑定到 Automator 服务,请启动“系统偏好设置”并转到 键盘 > 快捷键 > 服务
,找到您的服务并为其添加快捷键。