Created
June 20, 2018 14:21
-
-
Save mlegner/17a992baa2de8c83b36ca08aa7dd9938 to your computer and use it in GitHub Desktop.
Short script that connects properly to my bluetooth headphones and enables A2DP mode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Connect to the bluetooth headphones properly and enable A2DP | |
mac="AA:AA:AA:AA:AA:AA" # the MAC address of the bluetooth headphones | |
cardname="bluez_card.AA_AA_AA_AA_AA_AA" # the audio-card name associated with the bluetooth headphones | |
timeout=5 # timeout for connecting | |
coproc bluetoothctl | |
echo -e "connect $mac" >&${COPROC[1]} | |
timeout $timeout grep -q "ServicesResolved: yes" <&${COPROC[0]} || echo -e "connect $mac" >&${COPROC[1]} | |
echo -e "exit" >&${COPROC[1]} | |
echo Connecting to card $cardname | |
pacmd set-card-profile $cardname off | |
pacmd set-card-profile $cardname a2dp_sink | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment