7

I've been trying to find a consistent shell command to adjust the volume on my laptop. I was recommended to try (for muting/unmuting):

 pactl set-sink-mute 0 toggle

and it didn't work, I got the error

Failed to get sink information: No such entity

After some more looking, I found out that changing 0 to 1 in the command worked. I think this is because pactl assigns my sound card a number when it starts up, and that number changed when I restarted my laptop.

That was fine, but when I restarted my laptop the audio keys aren't working again. I tried the working command in the shell and got the "No such entity" error again. If I changed 1 back to 0 (i.e. the original command), it works again.

This is confusing to me, because I think I only have one sound card. In any case, if the number assigned to the card isn't consistent, is there a consistent way to refer to that card and adjust its volume?

13

A laptop may have only one audio card, but can have more than one Pulseaudio sink for audio playback.

To see a list of available sinks:

pactl list short sinks

Sink index numbers are assigned during boot, and the order of sinks can change between boots. To ensure the mute command works on the correct sink use the symbolic name instead of the index number.

For example:

The sinks on my system are listed as:

$ pactl list short sinks
0       alsa_output.pci-0000_00_1b.0.analog-stereo      module-alsa-card.c      s16le 2ch 44100Hz       RUNNING
1       alsa_output.pci-0000_01_00.1.hdmi-stereo-extra1 module-alsa-card.c      s16le 2ch 44100Hz       SUSPENDED

The device that is RUNNING is the one to be muted:

symbolic name = alsa_output.pci-0000_00_1b.0.analog-stereo

so the command to toggle mute state on that device is:

$ pactl set-sink-mute alsa_output.pci-0000_00_1b.0.analog-stereo toggle
1
  • 1
    Or you could. also do "pactl set-sink-mute 0 toggle" where 0 is the index associated with the RUNNING card.
    – CM3
    Jun 26 at 12:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.