I'm trying to switch between the audio outputs of my video card from the command line. I'm able to do that via the GUI settings, as it's shown on the picture. How can I do this programmatically?
On the picture are presented two audio devices wit two outputs each:
(green) Device 1 - Built-in Audio with two outputs:
- Digital Output
- Headphones
(red) Device 2 - HDMI Audio Controller of NVidia GTX 660. To the video card are connected two monitors:
The first monitor is LG TV and it is connected to HDMI-0.
The second monitor is LG ULTRAWIDE and it is connected to DVI-I-1.
So I want to switch, via the command-line, between the red outputs (the two monitors). Everything I've found, in my research, is how to switch between the audio devices (sound cards). I've already read few topics as these questions:
- Audio output device, fast switch?
- How to change pulseaudio sink with "pacmd set-default-sink" during playback?
- How can I choose the audio output device using the terminal?
- How to switch sound output with key shortcut
When the first monitor LG TV | HDMI-0 is engaged as audio output:
$ pactl list sinks short
8 alsa_output.pci-0000_00_1b.0.analog-stereo module-alsa-card.c s16le 2ch 44100Hz SUSPENDED
16 alsa_output.pci-0000_03_00.1.hdmi-stereo module-alsa-card.c s16le 2ch 44100Hz RUNNING
$ pacmd list-sinks | grep name:
name: <alsa_output.pci-0000_00_1b.0.analog-stereo>
name: <alsa_output.pci-0000_03_00.1.hdmi-stereo>
When the second monitor LG ULTRAWIDE | DVI-I-1 is engaged as audio output:
$ pactl list sinks short
8 alsa_output.pci-0000_00_1b.0.analog-stereo module-alsa-card.c s16le 2ch 44100Hz SUSPENDED
17 alsa_output.pci-0000_03_00.1.hdmi-stereo-extra1 module-alsa-card.c s16le 2ch 44100Hz RUNNING
$ pacmd list-sinks | grep name:
name: <alsa_output.pci-0000_00_1b.0.analog-stereo>
name: <alsa_output.pci-0000_03_00.1.hdmi-stereo-extra1>
The output of pacmd list-cards
and pactl list cards
is provided here.
You can see (in this particular case) I'm searching for a way to switch between sink 16
and sink 17
. But when sink 16
is presented in pactl list sinks
, sink 17
is not presented and vice versa. I can switch them only from the GUI settings. Is ithere a way to do that via the command-line?
pactl set-default-sink alsa_output.pci-0000_00_1b.0.analog-stereo
orpactl set-default-sink alsa_output.pci-0000_03_00.1.hdmi-stereo-extra1
?Failure: No such entity
.alsa_output.pci-0000_03_00.1.hdmi-stereo
butalsa_output.pci-0000_03_00.1.hdmi-stereo-extra1
. Don't get the point from your link?pacmd list-cards
/pactl list cards
. The correct syntax of the commands is: (1)pactl set-card-profile alsa_card.pci-0000_03_00.1 output:hdmi-stereo
and (2)pactl set-card-profile alsa_card.pci-0000_03_00.1 output:hdmi-stereo-extra1
. (Wherealsa_card.pci-0000_03_00.1
is the card name andoutput:hdmi-stereo*
are the profile names.) These commands creates newsinc #
and deletes the previewssinc #
of this card.