Skip to content

Instantly share code, notes, and snippets.

@tyjak
Created January 10, 2022 17:01
Show Gist options
  • Save tyjak/418ff6f6ff9f3c0ea5adc22fcf43d65b to your computer and use it in GitHub Desktop.
Save tyjak/418ff6f6ff9f3c0ea5adc22fcf43d65b to your computer and use it in GitHub Desktop.
#!/bin/zsh
# switch a2dp ot hfh codec for bluetooth headset to have quality sound or mic
# GistID: 418ff6f6ff9f3c0ea5adc22fcf43d65b
HEADSET=$1
HIGH_QUALITY=$(pacmd list-cards | grep -B5 -A20 -c -e 'active profile: <a2dp_sink>' -e 'device.description = "'$HEADSET'"')
echo "test: $HIGH_QUALITY"
QUALITY=a2dp_sink
if [ $HIGH_QUALITY -eq 2 ]
then
QUALITY=handsfree_head_unit
fi
pacmd set-card-profile $(pacmd list-cards | grep -B5 'device.description = "'$HEADSET'"' | head -1 | cut -d":" -f2 | tr -d " ") $QUALITY
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment