Automatically change Sound Input Output device

Solution 1:

There is pulseaudio module-switch-on-connect and module-switch-on-port-available that enable automatic switching of an audio device on connection. See with the following command if any of these modules is already loaded:

pactl list short modules

If not, then test if you can make automatic switching work by issuing one or both of the following commmands in a terminal:

pactl load-module module-switch-on-connect
pactl load-module module-switch-on-port-available

On success add one or both of the following lines to your /etc/pulse/default.pa

load-module module-switch-on-connect
load-module module-switch-on-port-available

This will then always load these modules on every login, resp. restart of the pulseaudio daemon.

Please note that local user settings in ~/.config/pulse/default.pa override system-wide setting. If you have such a local file you will enter the above commands there.

If it still not works you may have conflicting settings in such a local default.pa. It then may worth to (temporarily) rename this file followed by a restart of the Pulseaudio server before trying above again:

mv ~/.config/pulse/default.pa ~/.config/pulse/default.pa.old
pulseaudio -k

Solution 2:

create ~/.config/pulse/default.pa if it doesn't exist and append

.include /etc/pulse/default.pa
load-module module-switch-on-connect

This is better than editing /etc/pulse/default.pa.

Afterwards you should run pulseaudio -k && pulseaudio --start to have the changes take effect. Thanks for pointing that out lreeder