The PulseAudio Auto-Switching Annoyance
In Ubuntu Linux, the default audio server (PulseAudio) is designed to be helpful. Whenever you plug in a new pair of headphones, connect a USB microphone, or connect a monitor via HDMI, the system automatically switches your default audio output to that newly connected device. While this is convenient for a laptop user plugging in headphones, it is incredibly frustrating for desktop users whose audio randomly cuts out because the system decided to route the sound to a newly connected monitor that doesn’t even have speakers.
How to Disable the PulseAudio Switch-on-Connect Module
To stop this automatic switching, you need to edit the core PulseAudio configuration file and disable the specific module responsible for the behaviour.
1. Open your terminal by pressing Ctrl + Alt + T.
2. Open the main PulseAudio configuration file using a text editor with root privileges (we will use nano):
sudo nano /etc/pulse/default.pa
3. Press your password when prompted.
4. Use the arrow keys to scroll down through the file until you find the following line (it is usually near the bottom):
load-module module-switch-on-connect
5. Add a hashtag (#) to the very beginning of the line to “comment it out” and disable it. It should now look exactly like this:
#load-module module-switch-on-connect
6. Save the file and exit the editor (Press Ctrl+O, Enter, then Ctrl+X).
Applying the Changes
For the new configuration to take effect, you must restart the audio server. Back in the terminal, type pulseaudio -k and press Enter to kill the current session (it will automatically restart itself within a few seconds). From now on, when you plug in a new device, Ubuntu will acknowledge its presence but will leave your current audio output exactly where it is, requiring you to manually switch the audio source in the Settings menu if you actually want to use it.