Last active
February 16, 2024 22:54
-
-
Save gpchelkin/b2fa4162272cfae4b5c0276237edd968 to your computer and use it in GitHub Desktop.
PulseAudio: switch Bluez card A2DP Audio Profile off and on and set it as default sink to disable lags.
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 | |
# Tested on Linux Mint 18.3 / Ubuntu 16.04 with PulseAudio 8.0. | |
# No need for superuser. | |
# You can map it to keyboard shortcut and press when bluetooth audio starts lagging. | |
# Reference: | |
# https://askubuntu.com/a/171165/373130 | |
# https://askubuntu.com/a/72076/373130 | |
BLUEZCARD=`pactl list cards short | grep bluez | awk '{print $1}'` | |
pactl set-card-profile $BLUEZCARD off | |
pactl set-card-profile $BLUEZCARD a2dp_sink | |
# NOTE: You may have different profile names, for list of it execute: | |
#pactl list cards | |
# and look for: | |
# Card with name bluez: Ports: headset-output: Part of profile(s): | |
BLUEZSINK=`pactl list sinks short | grep bluez | awk '{print $1}'` | |
pactl set-default-sink $BLUEZSINK | |
# NOTE: You may also need to move active input sinks: | |
#pacmd list-sink-inputs | |
# and iterate through its indexes: | |
#pacmd move-sink-input 5 $BLUEZSINK | |
# but in my case input sinks are moved automatically |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment