~cyplo/dotfiles

ref: 83ddcc09dc68389b129d598722eca9e90a6dff33 dotfiles/tools/fix-a2dp-bluetooth -rwxr-xr-x 790 bytes
83ddcc09 — Cyryl Płotnicki remove broken i3 msg call 1 year, 10 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