I believe you can do this using a number of tools, such as amixer
, or pamd
, or pactl
.
NOTE: Your assumption is how I understand things as well. Sinks I equate to actual soundcards (output), and the outputs on them are called ports.
The actual definition from this guide titled PulseAudio under the hood:
Sink
A sink is an output device. It is an active unit that consumes samples.
Sink usually runs a thread with its own event loop, peeks sample chunks from connected sink inputs, and mixes them. It also implements clocking and maintains latency. The rest of the world usually communicates with a sink using messages.
The typical sink represents an output sound device, e.g. headphones connected to a sound card line output or on a Bluetooth headset. PulseAudio automatically creates a sink for every detected output device.
Example
Here's an example showing how to use pactl
:
$ pactl list sinks |& grep -E "Sink|Ports|analog-ou"
Sink #0
Ports:
analog-output-lineout: Line Out (priority: 9900, not available)
analog-output-headphones: Headphones (priority: 9000, not available)
Active Port: analog-output-lineout
Above you can see my Active Port:
is currently my soundcard's lineout. Let's change that to the headphones.
$ pactl set-sink-port 0 analog-output-headphones
And if we check again:
$ pactl list sinks |& grep -E "Sink|Ports|analog-ou"
X11 connection rejected because of wrong authentication.
Sink #0
Ports:
analog-output-lineout: Line Out (priority: 9900, not available)
analog-output-headphones: Headphones (priority: 9000, not available)
Active Port: analog-output-headphones
From man pactl
:
set-sink-port SINK PORT
Set the specified sink (identified by its symbolic name or
numerical index) to the specified port (identified by its symbolic
name).
What if audio device disappears?
In rare cases I've noticed that the audio output device mysteriously disappears from the list of devices. If you find this happens you can easily resolve this by telling Pulse Audio to reload its modules:
$ pactl load-module module-detect
References
amixer
is the commandline version ofalsamixer
– Ipor Sircer Jul 30 '18 at 00:09