Created
February 2, 2022 19:48
-
-
Save sjbodzo/f67a4ba947b76c5ac6d28792bed64675 to your computer and use it in GitHub Desktop.
fix a2dp issue on bluetooth pair
This file contains hidden or 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 | |
bt_device_addr=$(pacmd list-cards | grep -i 'name:.*bluez_card' | sed -E 's/.*<?bluez_card\.([A-Z0-9_]+)>?/\1/') | |
device_mac=$(echo $bt_device_addr | sed 's/_/:/g') | |
a2dp_available=$(pacmd list-cards | grep -A30 bluez | grep "A2DP Sink" | sed -E 's/.* available: ([a-z]+)\)/\1/g') | |
if [[ "$a2dp_available" == "no" ]] || [[ "$a2dp_available" == "unknown" ]] | |
then | |
dbus-send --system --dest=org.bluez --print-reply /org/bluez/hci0/dev_$bt_device_addr org.bluez.Device1.Connect | |
pacmd set-card-profile bluez_card.$bt_device_addr off | |
pacmd set-card-profile bluez_card.$bt_device_addr a2dp_sink | |
pacmd set-default-sink bluez_sink.$bt_device_addr.a2dp_sink | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment