~cyplo/dotfiles

ref: 1ca69547b9a678da7a89ac93b7822ac478a2ab7d dotfiles/tools/fix-a2dp-bluetooth -rwxr-xr-x 790 bytes
1ca69547 — Cyryl Płotnicki update 5 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/bash
set -e

card_index=`pacmd list-cards | grep bluez_card -B1 | grep index | awk '{print $2}'`
card_address=`pacmd list-cards | grep bluez_card -A8 | grep 'device\.string' | awk '{print $3}'`
card_address=${card_address//\"/}

if [[ -z $card_index ]]; then
    echo "cannot determine card index, please make sure the headset is on and paired"
    exit 1
fi

echo "switching card number $card_index off"
pacmd set-card-profile $index off;
sleep 2
echo "reconnecting $card_address"
echo "disconnect $card_address" | bluetoothctl
sleep 3
echo "connect $card_address" | bluetoothctl
sleep 5
card_index=`pacmd list-cards | grep bluez_card -B1 | grep index | awk '{print $2}'`
echo "new index is $card_index"
echo "changing the card profile"
pacmd set-card-profile $card_index a2dp_sink