Linux: Auto Switch to Bluetooth Headset
• 158 words • 1 min • updated
⚠️ This post is over one year old. It may no longer be up to date or relevant. Opinions may have changed.
Whenever I connect/disconnect my bluetooth headphones to my Linux workstation, I need to manually switch to/off them.
Every commercial OS I’m aware of does that automatically, including Chrome OS, macOS and Windows.
To automate this behavior on Linux, it depends whether we’re using PulseAudio or Pipewire. It boils down to loading the module-switch-on-connect pulseaudio module.
Note: Tested on Arch Linux only.
PulseAudio #
shell
$ sudoedit /etc/pulse/default.pa
...
load-module module-switch-on-connect
...Then restart pulseaudio:
shell
$ systemctl --user restart pulseaudioPipeWire #
shell
$ sudo mkdir -p /etc/pipewire
$ sudo cp /usr/share/pipewire/pipewire-pulse.conf /etc/pipewire/pipewire-pulse.conf
$ sudoedit /etc/pipewire/pipewire-pulse.conf
...
# Extra modules can be loaded here. Setup in default.pa can be moved here
context.exec = [
{ path = "pactl" args = "load-module module-switch-on-connect" }
]
...Alternatively, ~/.config/pipewire/pipewire-pulse.conf should also work. We
should not edit the file in /usr because it will not survive package
upgrades.
Then restart pipewire:
shell
$ systemctl --user restart pipewire{,-pulse}