Created
November 4, 2021 19:38
-
-
Save victor-oliveira1/a49e66c333e405f64b33606796975391 to your computer and use it in GitHub Desktop.
Switch profiles on bluez cards with alsa (A2DP and HFP)
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
#!/usr/bin/env bash | |
# Switch profiles between bluez cards (A2DP and HFP) | |
# Check profiles and cards with: pactl list cards | |
# Victor Oliveira <[email protected]> | |
CARD="bluez_card.AA_BB_CC_DD_EE_FF" | |
while read LINE; do | |
test -n "${CARD_FOUND}" && { | |
grep "Perfil ativo:" <<<"${LINE}" &> /dev/null && { | |
ACTIVE_PROFILE="${LINE#*: }" | |
break | |
} | |
} | |
grep "${CARD}" <<<"${LINE}" &> /dev/null && { | |
CARD_FOUND=1 | |
} | |
done < <(pactl list cards) | |
test "${ACTIVE_PROFILE}" == "a2dp_sink" && { | |
pactl set-card-profile "${CARD}" handsfree_head_unit | |
} || { | |
pactl set-card-profile "${CARD}" a2dp_sink | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment