Last active
January 10, 2022 11:19
-
-
Save NishargShah/6a9de191484f0842bd9d7806ea2fdac3 to your computer and use it in GitHub Desktop.
Help to toggle sound profile from a2dp to hsp or hsp to a2dp
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 | |
SINK=$(pacmd list-cards | grep bluez) | |
MAC=${SINK:19:17} | |
SINK=$(pacmd list-sinks | grep index | grep -vw "index: 0") | |
INDEX=${SINK:11:2} | |
BT_SINK="bluez_card.$MAC" | |
A2DP="a2dp_sink" | |
HSP="headset_head_unit" | |
SINK=$(pacmd list-sinks | grep bluetooth.protocol) | |
ACTIVE_SINK=${SINK:24:-1} | |
if [ $ACTIVE_SINK = $HSP ]; then | |
echo Setting A2DP audio sink $BT_SINK | |
pacmd set-default-sink $INDEX | |
pactl set-card-profile $BT_SINK $A2DP | |
elif [ $ACTIVE_SINK = $A2DP ]; then | |
echo Setting HSP headset sink $BT_SOURCE | |
pacmd set-default-sink $INDEX | |
pactl set-card-profile $BT_SINK $HSP | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment