Last active
April 16, 2024 03:51
-
-
Save rkok/58ee4d27dd31cddb81385c78cd3cc2fa to your computer and use it in GitHub Desktop.
PulseAudio headset mode toggler
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 | |
####################### | |
# btheadset_toggle.sh | |
# | |
# Toggles bluetooth headset mode between | |
# A2DP (high quality, no microphone) | |
# and headset (low quality + microphone). | |
# | |
# Usage: ./btheadset_toggle.sh | |
# | |
# Setup: | |
# 1. Run `pacmd list-cards` | |
# 2. Check what the name of your card is and fill it in below | |
# 3. Check the naming of PROFILE_A2DP / PROFILE_HSP | |
# and modify below if necessary | |
# 4. Recommended: create a panel launcher to run this script | |
####################### | |
ID="bluez_card.AA_BB_CC_DD_EE_FF" # <-- Your card ID here | |
PROFILE_A2DP='a2dp_sink' | |
#PROFILE_HSP='headset_head_unit' | |
PROFILE_HSP='handsfree_head_unit' | |
CUR_PROFILE="$(pacmd list-cards | grep -A 40 $ID | grep 'active profile' | head -1 | awk '{print $3}' | sed 's/[<>]//g')" | |
if [ "$CUR_PROFILE" == "$PROFILE_A2DP" ]; then | |
# Need to do this twice for some reason | |
pacmd set-card-profile $ID $PROFILE_HSP | |
pacmd set-card-profile $ID $PROFILE_HSP | |
else | |
pacmd set-card-profile $ID $PROFILE_A2DP | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment