Skip to content

Instantly share code, notes, and snippets.

@akirattii
Last active October 30, 2016 22:29
Show Gist options
  • Save akirattii/6f6e592246717e88b4a1b8d2676477c4 to your computer and use it in GitHub Desktop.
Save akirattii/6f6e592246717e88b4a1b8d2676477c4 to your computer and use it in GitHub Desktop.
BTヘッドセットを使うためのシェル ($ ./bt-audio.sh { connect | disconnect })
#!/bin/bash
# Device E3:28:E9:21:61:5E TaoTronics TT-BH07
mac="E3:28:E9:21:61:5E"
devname="TaoTronics TT-BH07"
# このshを使う前にあらかじめペアリングしておく:
# $ bluetoothctl
# ...
# [NEW] Device E3:28:E9:21:61:5E TaoTronics TT-BH07
# ...
# [bluetooth]# pair E3:28:E9:21:61:5E
#
# Usage:
# ### Connect:
# $ ./bt-audio.sh connect
# ### Disconnect:
# $ ./bt-audio.sh disconnect
#
connectOrDisconnect=$1
if [ $# -ne 1 ]; then
echo "Needs an argument 'connect' or 'disconnect'. Nothing is done..."
exit
fi
# enable bluetooth
sudo systemctl start bluetooth
sleep 1
# run the program bluez
echo "${connectOrDisconnect}ing bluetooth audio device '${devname}' (${mac}) ..."
echo -e 'power on\n'${connectOrDisconnect}' '$mac' \nquit' | bluetoothctl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment