3 device
='FC:A8:9A:57:A4:8A'
4 device_sink
='FC_A8_9A_57_A4_8A'
5 device_name
="JBL Headset"
9 # usermod -a -G bluetooth $USER
11 dmenu
-P -p "sudo " | sudo
-S sh
-c\
12 "rfkill unblock bluetooth
15 # sudo rfkill block wlan && sudo modprobe -r btusb && sleep 10 && sudo modprobe btusb && systemctl --user restart pulseaudio && sudo systemctl restart bluetooth
16 # modprobe btusb ;sudo systemctl start bluetooth
20 bstatus
=$
(pgrep bluetoothd
)
21 bl_s
=$
(rfkill
-rn |
awk '/bluetooth/ {print $4}')
22 if [ ! "$bstatus" ] ||
[ "$bl_s" != "unblocked" ]; then
28 is_connected
=$
(bluetoothctl info
$device |
awk '/Connected/ {print $2}')
29 if [ ! "$is_connected" = "yes" ]; then
30 bluetoothctl power off
32 bluetoothctl disconnect
$device
33 bluetoothctl pair
$device
34 bluetoothctl connect
$device
35 bluetoothctl trust
$device
39 change
=$
(pacmd set-card-profile bluez_card.
$device_sink a2dp_sink |\
41 if [ "$change" = "Failed" ]; then
45 pacmd set-default-sink bluez_sink.
$device_sink.a2dp_sink
46 inputs
=$
(pacmd list-sink-inputs |
awk '$1 == "index:" {print $2}')
47 for apps
in $inputs; do
48 pacmd move-sink-input
"$apps" bluez_sink.
$device_sink.a2dp_sink