Posted about 1 month ago. Visible to the public.

How to set a fixed microphone source in Ubuntu if it keeps changing

In some circumstances it's possible for Ubuntu to switch the default microphone on its own, e.g. if you're using a headset connected by a 3,5mm plug and your USB webcam also has a microphone, Ubuntu might set the default microphone to the USB one in the webcam.

If that's not what you want, it's suprisingly hard to tell Ubuntu not to do it. Here is how.

Alternatively, you may disable all devices but the one you want to use. Note that this is not always applicable, e.g. if you want to keep your other input devices to manually switch to them.

How to set the microphone source on login

Setting the microphone source on login be late enough in the startup process for the microphone selection not to be overwritten by any usb hotplug events, so that's where we're putting the scripts.

Preparation

First, find out the exact names of the input sources:

Copy
$ pactl list short sources 0 alsa_input.usb-046d_0825_A3C41A40-02.analog-mono module-alsa-card.c s16le 1ch 48000Hz SUSPENDED 1 alsa_output.pci-0000_00_1f.3.analog-stereo.monitor module-alsa-card.c s16le 2ch 44100Hz IDLE 2 alsa_input.pci-0000_00_1f.3.analog-stereo module-alsa-card.c s16le 2ch 44100Hz SUSPENDED

Pick the one you want. You most certainly won't want to pick the monitor one and, in our example, not the USB webcam.

Set the input source;

Copy
$ pactl set-default-source 'alsa_input.pci-0000_00_1f.3.analog-stereo'

This should select the correct microphone and also be reflected in Ubuntu's GUI dialog.

Apply those settings on every login

1) Find a good place to put your script, e.g. in $HOME/bin/set-microphone.sh.
2) Enter the following content. Make sure to use the source you identified in the step above.

Copy
#!/bin/bash pactl set-default-source 'alsa_input.pci-0000_00_1f.3.analog-stereo'

3) Allow the file to be executed

Copy
chmod +x $HOME/bin/set-microphone.sh

4) Save the script and add it to your Startup Applications Preferences like so:

Image

After a new login, it should no auto-select the correct microphone.

Owner of this card:

Avatar
Florian Heinle
Last edit:
about 1 month ago
by Arne Hartherz
Attachments:
Screenshot_from_2020-02-14_11-01-50.png
Posted by Florian Heinle to makandra orga
This website uses cookies to improve usability and analyze traffic.
Accept or learn more