PulseAudio is nowadays the default sound system in many Linux distributions. It lets you do a number of useful things.

PulseAudio comes with a handy command line utility pacmd to do a number of things.

pacmd commands

  • pacmd exit
  • pacmd help
  • pacmd list-(modules sinks sources clients cards samples)
  • pacmd list-(sink-inputs source-outputs)
  • pacmd stat
  • pacmd info
  • pacmd load-module NAME [ARGS …]
  • pacmd unload-module NAME #N
  • pacmd describe-module NAME
  • pacmd set-(sink source)-volume NAME #N VOLUME
  • pacmd set-(sink-input source-output)-volume #N VOLUME
  • pacmd set-(sink source)-mute NAME #N 1 0
  • pacmd set-(sink-input source-output)-mute #N 1 0
  • pacmd update-(sink source)-proplist NAME #N KEY=VALUE
  • pacmd update-(sink-input source-output)-proplist #N KEY=VALUE
  • pacmd set-default-(sink source) NAME #N
  • pacmd kill-(client sink-input source-output) #N
  • pacmd play-sample NAME SINK #N
  • pacmd remove-sample NAME
  • pacmd load-sample NAME FILENAME
  • pacmd load-sample-lazy NAME FILENAME
  • pacmd load-sample-dir-lazy PATHNAME
  • pacmd play-file FILENAME SINK #N
  • pacmd dump
  • pacmd move-(sink-input source-output) #N SINK SOURCE
  • pacmd suspend-(sink source) NAME #N 1 0
  • pacmd suspend 1 0
  • pacmd set-card-profile CARD PROFILE
  • pacmd set-(sink source)-port NAME #N PORT
  • pacmd set-port-latency-offset CARD-NAME CARD-#N PORT OFFSET
  • pacmd set-log-target TARGET
  • pacmd set-log-level NUMERIC-LEVEL
  • pacmd set-log-meta 1 0
  • pacmd set-log-time 1 0
  • pacmd set-log-backtrace FRAMES

Changing audio output from the command line

For this I use the pacmd utility and manipulate the sink inputs. For already running streams, the move-sink-input needs to be used.

I have a PC with a weird configuration and requires me to switch profiles instead.

Get the current active profile:

pacmd list-cards | grep 'active profile'

Set the active profile:

pacmd set-card-profile #card #profile#

Example commands:

pacmd set-card-profile 0 output:analog-stereo+input:analog-stereo
pacmd set-card-profile 0 output:hdmi-stereo+input:analog-stereo

All that logic is in a script here or download from this link.

MATE control crashing status icon

For some reason the sound control icon in the notification bar gets lost for me. To make it re-appear use this command:

mate-volume-control-status-icon