How to prevent Ubuntu from switching default audio output device to Analog Output when docked? [duplicate]

I have 19.04 on a Lenovo ThinkPad T580. When my laptop is not docked, default audio output device is "Speakers - built-in". But when I put my laptop in a docking station, it changes default audio output device to "Analog Output - ThinkPad Dock USB Audio".

I don't have any speakers connected to my dock, so I would like to continue to have audio out of the built-in speakers. Of course, I can just change it back manually every time I dock my computer, but it would be much nicer, if it just stopped changing default audio output device whenever I docked my computer.

Any ideas how to accomplish this?


I found a solution to this.

  1. Open this file in an editor /etc/pulse/default.pa
  2. Find and comment out the line containing this load-module module-switch-on-connect
  3. Then, restart pulseaudio with pulseaudio -k

This solution was modified from https://danielgibbs.co.uk/2019/06/prevent-automatic-change-of-audio-device-ubuntu/