Skip to content

Instantly share code, notes, and snippets.

@victor-oliveira1
Created November 4, 2021 19:38
Show Gist options
  • Save victor-oliveira1/a49e66c333e405f64b33606796975391 to your computer and use it in GitHub Desktop.
Save victor-oliveira1/a49e66c333e405f64b33606796975391 to your computer and use it in GitHub Desktop.
Switch profiles on bluez cards with alsa (A2DP and HFP)
#!/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