8

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?

3 Answers 3

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. Jun 26, 2021 at 12:11
1

These two work for me:

1: use xdotool

$ xdotool key XF86AudioLowerVolume #decrease volume
$ xdotool key XF86AudioRaiseVolume #increase volume

2: Use this to see index of your audio devices:

$ pacmd list-sinks | grep -e 'name:' -e 'index:'
  index: 1
  name: <alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp_5__sink>
  index: 2
  name: <alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp_4__sink>
  index: 3
  name: <alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp_3__sink>
* index: 4
  name: <alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp__sink>

Before the index: 4 there is an asterisk. It the device I need:

$ pactl set-sink-volume 4 +10%
$ pactl set-sink-volume 4 -10%
0

For me has helped to restart an audio driver:

pulseaudio -k && sudo alsa force-reload

After pact.... command worked without any error.

pactl -- set-sink-volume 0 125%

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .