Skip to content

Instantly share code, notes, and snippets.

@diffficult
Last active June 18, 2023 05:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diffficult/37360df0824137e04659e7f5ebf9a561 to your computer and use it in GitHub Desktop.
Save diffficult/37360df0824137e04659e7f5ebf9a561 to your computer and use it in GitHub Desktop.
LINUX - Switch your main audio output to your headset when bluetooth connects

Auto switch audio output when a new Bluetooth device connects

Depending on the distro or DE/WM you are running and which programs you are using to manage your audio you maybe run into the hassle of having to switch audio outputs each time you connect a bluetooth device (headset/speaker). You can in fact make pulseaudio to autoswitch when connection is established and not do it manually.

To accomplish this you just need to check a condition in the default.pa config file located in /etc/pulse/ directory on your install and add the following line load-module module-switch-on-connect like in the code snippet below:

...

### Automatically load driver modules for Bluetooth hardware
.ifexists module-bluetooth-policy.so
load-module module-bluetooth-policy
.endif

.ifexists module-bluetooth-discover.so
load-module module-bluetooth-discover
load-module module-switch-on-connect  # <<<<<< add this to let audio sink to autoswitch to the newly conencted BT device
.endif

...

after that just restart pulseaudio daemon with pulseaudio -k to let changes take effect an try it out turning bluetooth on and just turning on your headset and letting it connect automatically.


Source: https://askubuntu.com/questions/589885/automatically-switch-sound-output-device-to-bluetooth-headset-force-to-a2dp-pr


Pipewire auto switch audio profile on bluetooth connect

Need to run this on startup


pactl load-module module-switch-on-connect


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment