I can change the master volume with these commands (from the command line), and it affects all applications, but how do I change the volume for just one application (XMMS for example)?

amixer -q  set Master     toggle  # or pactl set-sink-mute   0 toggle
amixer -q sset Master 5%+ unmute  # or pactl set-sink-volume 0 -- -5%
amixer -q sset Master 5%- unmute  # or pactl set-sink-volume 0 -- +5%

pacmd dump # is interesting, and there are GUI applications that can do this: gnome-control-center sound, pavucontrol

  • You can't do that with ALSA, but you can do it with Pulseaudio. – Gilles Jun 10 '15 at 21:13

You can get the number of sink Input with pactl command.

$ pactl list sink-inputs
...
Sink Input #7119
    Driver: protocol-native.c
    Owner Module: 12
    Client: 6298
    Sink: 0
...
Properties:
    application.icon_name = "google-chrome"
    media.name = "Playback"
    application.name = "Chromium"
...

Using this number(#7119), you specify the sink Input.

$ pactl set-sink-input-mute 7119 toggle

It will identify the application with application.icon_name property. The following is a case to specify the Chromium.

#!/bin/sh
LANGUAGE="en_US"

app_name="Chromium"

current_sink_num=''
sink_num_check=''
app_name_check=''

pactl list sink-inputs |while read line; do \
    sink_num_check=$(echo "$line" |sed -rn 's/^Sink Input #(.*)/\1/p')
    if [ "$sink_num_check" != "" ]; then
        current_sink_num="$sink_num_check"
    else
        app_name_check=$(echo "$line" \
            |sed -rn 's/application.name = "([^"]*)"/\1/p')
        if [ "$app_name_check" = "$app_name" ]; then
            echo "$current_sink_num" "$app_name_check"

            pactl set-sink-input-mute "$current_sink_num" toggle
        fi
    fi
done

For PulseAudio Roland Haas has written a tool:
https://github.com/rhaas80/pa_volume

I had to install libpulse-dev linux-libc-dev libc6-dev zlib1g-dev libpcre3-dev libglib2.0-0 libglib2.0-dev.
You might also need a compiler (gcc) to make.

Source: https://askubuntu.com/a/968540/382812 "How to change volume of pulseaudio playback-apps / -streams that aren't currently in use?"

  • 1
    This is possibly useful technical information that does not address the question at all. – Jeff Schaller Mar 25 at 13:51
  • Why not? The question only says "maybe amixer or pactl". – äxl Mar 26 at 14:46
  • It seems to me that this answer points to a link which points to a link to a tool that may answer the question. Perhaps you could make it more obvious to casual readers of this site what you're suggesting by incorporating the AU answer here (with a link back to AU). Otherwise, this answer currently looks like an attempt to solve a make/compilation error. Thank you! – Jeff Schaller Mar 26 at 14:58

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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