【macOS】blueutil でBluetoothをコマンドラインから操作する

IT

ヘッドホンの接続をコントロールしたくなり、コマンドラインからBluetoothを操作するコマンドについて調べたところ、blueutilというものを見つけたので試した。

インストール

Homebrewでblueutilをインストールする。

brew install blueutil

コマンド実行

全てはblueutil [options]の形で実行する。

電源系オプション

-p, --power 0             Bluetoothの電源OFF
-p, --power 1             Bluetoothの電源ON
-p, --power               現在のBluetooth電源状態を表示する

ペアリング系オプション

    --inquiry [T]         デバイスを探す(Tはタイムアウトの秒数でデフォルト値は10)
    --pair ID [PIN]       デバイスとペアリングする
    --paired              ペアリング済みのデバイス一覧を表示する
-d, --discoverable 0      検出可能モードOFF
-d, --discoverable 1      検出可能モードON
-d, --discoverable        現在の検出可能モードを表示する

・addressの文字列がIDにあたる。
・ペアリングを解除する--unpair的なオプションはOSの制約があって実装されていない。

接続系オプション

ペアリングしただけではヘッドホンは聞こえない。「接続」する必要がある。

--connect ID          デバイスに接続する
--disconnect ID       デバイスとの接続を切る

【参考サイト】

https://trevorsullivan.net/2019/07/30/control-bluetooth-on-apple-macbook-pro-from-the-command-line/
one important option is missing - Unpair Paired Bluetooth Device · Issue #27 · toy/blueutil
because I'm using Bluetooth wireless keyboard with 2 computers every time I want to connect to the other one, I have to repair the keyboard with the computer Bl...
IT
広告
一郎くんどっとこむ