0

I'm running PulseAudio on Xubuntu 20.04. I have three audio devices that we'll just call Device A, Device B, and Device C. All three have a mic and an audio out option, and they all show up correctly under Input Devices and Output Devices when plugged in.

However, I would like PulseAudio to switch to some devices but not others when they're plugged in. Essentially, here's what I'm looking for:

  • Device A gets plugged in -> PulseAudio automatically switches to it for both Input and Output Devices.
  • Device B gets plugged in -> PulseAudio lists it but does not switch to it
  • Device C gets plugged in -> PulseAudio automatically switches to it for the Output Device but not the Input Device.

Is there a way to accomplish what I want? It seems like the only options under PulseAudio are to always switch to a new device when plugged in or never switch to it, and I want something in between.

EDIT: If I set a default device in PulseAudio, is it possible to then tell PulseAudio "switch to the default device when it's plugged in, but don't switch away when something else is plugged in afterward"?

5
  • Use "aplay -l" to determine the device names of your sources and sinks. Then study this URL "askubuntu.com/questions/14077/…". Commented Jul 3, 2021 at 21:32
  • @CinaedSimson Thank you for this link, but it appears to mostly be discussing how to change audio sources via command line. I don't want to have to manually run a command when I plug/unplug devices. I want each device to have its own automatic behavior when plugged in. Commented Jul 4, 2021 at 1:06
  • @ArtemS.Tashkinov I'm sorry, but I don't follow. I don't see "Settings" anywhere in the pavucontrol GUI. Commented Jul 4, 2021 at 1:07
  • Pulseaudio remembers the input/output devices per application, the default audio device is just the one that gets chosen for a new application, or if the remembered device cannot be found. So there's no way to do what you want easily. You could write a Pulseaudio application that monitors device and application events, and overrides the device choices based on that, but that's quite a bit of effort, and if you knew how to do that, you wouldn't be asking.
    – dirkt
    Commented Jul 4, 2021 at 4:04
  • @dirkt Okay, that makes sense. The issue is that I'm constantly unplugging and re-plugging audio devices, but it sounds like PulseAudio is built on a per-application paradigm and not a per-device paradigm. There's probably a market for some kind of application or plug-in like you described, so hopefully, someone will develop one at some point. In the meantime, I did recently start reading on udev scripting, so maybe I'll look into that more deeply. Commented Jul 4, 2021 at 16:05

1 Answer 1

0

The issue is that I'm constantly unplugging and re-plugging audio devices

As a workaround, create a null sink with a proper name (there's quite a few Q&A's here for this, use the search function), and then somehow automate a module-loopback (same) connection from the .monitor source of the null sink to the device you want. Via udev, or otherwise. In the beginning even three scripts that you execute manually may do.

Then you can point all of your applications' output to the null sink, and you won't have to deal with the switching per application.

The downside is slightly increased latency.

Do the analog thing with a second null sink for the inputs.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .