How to prevent automatic change of the audio device?

My Ubuntu 17.10 is connected via HDMI with my TV. HDMI ist the audio device I want always to use. Sometimes when the TV is turned off, Ubuntu switches the audio device tho semething else. When I turn on the TV again, I have to switch it back manually. How to prevent this automatic switching and set the audio device once and forever?


In /etc/pulse/default.pa comment out module-switch-on-port-available:

# load-module module-switch-on-port-available

Then restart.


You must deactivate all modules that start with module-switch-on-* in pulse audio service if you want to disable this behavior also with bluetooth and USB devices.

Ubuntu 18.04 and 20.04 LTS, for example:

  • module-switch-on-port-available
  • module-switch-on-connect

In a single instruction:

sudo sed -ri 's/^(load-module module-switch-on-.*$)/# \1/' /etc/pulse/default.pa

Then kill pulse audio or reboot:

pulseaudio -k