スクリプトはbluetoothctlからコマンドを実行しません。

スクリプトはbluetoothctlからコマンドを実行しません。

BluetoothヘッドフォンをLinuxシステムに自動的に接続する小さなスクリプトを作成しました。

#!/bin/bash

bluetoothctl
wait ${!}
connect XX:XX:XX:XX:XX:XX #headphone MAC address
wait ${!}
exit

スクリプトは開きますbluetoothctlが、次のコマンドは実行されません。

ベストアンサー1

bluetoothctl次のようにシェルスクリプトでコマンドを使用できます。

bluetoothctl -- command

または:

echo -e "command\n" | bluetoothctl

たとえば、

bluetoothctl -- connect XX:XX:XX:XX:XX:XX

おすすめ記事