Ubuntu – How to select a default sound card with alsa

alsapulseaudiosound

I wish to select a default sound card, or disable all others, in order to have the correct one selected after suspend.

Best Answer

  • This is a way set default sound output card dynamically using PulseAudio (not ALSA).

    1. Check list of Sources and Sinks

      $ pactl list short sources
      0   alsa_output.pci-0000_00_1b.0.analog-stereo.monitor  module-alsa-card.c  s16le 2ch 44100Hz   SUSPENDED
      1   alsa_input.pci-0000_00_1b.0.analog-stereo   module-alsa-card.c  s16le 2ch 44100Hz   SUSPENDED
      2   combined.monitor    module-combine-sink.c   s16le 2ch 44100Hz   SUSPENDED
      
      $ pactl list short sinks
      0   alsa_output.pci-0000_00_1b.0.analog-stereo  module-alsa-card.c  s16le 2ch 44100Hz   RUNNING
      1   combined    module-combine-sink.c   s16le 2ch 44100Hz   IDLE
      2   alsa_output.pci-0000_01_00.1.hdmi-stereo    module-alsa-card.c  s16le 2ch 44100Hz   RUNNING
      
    2. Set defaults:

      $ pactl set-default-source alsa_input.pci-0000_00_1b.0.analog-stereo
      $ pactl set-default-sink alsa_output.pci-0000_00_1b.0.analog-stereo
      

    It is possible even to set ports too. See How to switch sound output with key shortcut

    Reference: man pactl