The Audio Hijack
Ubuntu utilizes BlueZ (the official Linux Bluetooth protocol stack) and PulseAudio (or PipeWire in newer releases) to manage audio devices. When a previously paired Bluetooth speaker or headset is turned on and comes within range of your Ubuntu machine, the Bluetooth daemon automatically connects to it. More importantly, the audio server often automatically switches the default audio output “sink” to that newly connected device. While this is convenient if you intentionally turned on your headphones to listen to music, it is incredibly annoying if someone else in your house turns on a shared Bluetooth speaker, suddenly hijacking your laptop’s audio output in the middle of a video conference or movie.
Preventing Automatic Bluetooth Audio Routing
To retain manual control over where your sound plays and stop Ubuntu from automatically connecting to and routing audio through Bluetooth speakers, you must configure the PulseAudio module that handles hardware discovery.
You need to comment out a specific line in your PulseAudio configuration file. Open a terminal window (Ctrl+Alt+T). Type sudo nano /etc/pulse/default.pa and press Enter (input your password when asked). Use your arrow keys to scroll down through the file until you find a section dealing with Bluetooth (usually near the bottom). Look for the line that reads: load-module module-switch-on-connect. You need to disable this module. Type a hash symbol (#) at the very beginning of that line, so it looks like this: #load-module module-switch-on-connect. Save the file by pressing Ctrl+O and Enter, then exit nano with Ctrl+X. Finally, restart the audio server by typing pulseaudio -k and pressing Enter. From now on, when a Bluetooth speaker connects, Ubuntu will register it, but will not automatically switch your audio output to it; you must manually select it in the sound settings.