Posted over 2 years 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.


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

$ 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;

$ 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/
  2. Enter the following content. Make sure to use the source you identified in the step above.
#!/bin/bash pactl set-default-source 'alsa_input.pci-0000_00_1f.3.analog-stereo'
  1. Allow the file to be executed
chmod +x $HOME/bin/
  1. Save the script and add it to your Startup Applications Preferences like so:


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

Your development team has a full backlog of feature requests, chores and refactoring coupled with deadlines? We are familiar with that. With our "DevOps as a Service" offering, we support developer teams with infrastructure and operations expertise.

Owner of this card:

Florian Heinle
Last edit:
over 2 years ago
by Arne Hartherz
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Florian Heinle to makandra orga
This website uses short-lived cookies to improve usability.
Accept or learn more