Command line per-application volume (maybe amixer or pactl?)
Solution 1
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
Solution 2
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?"
Solution 3
If you're looking for a TUI that does what pavucontrol
does check out pulsemixer
.
It does just that,
You can see the Playback below, that shows all things playing to that sink (the sink-inputs).
Solution 4
My snippet for playback volume control to change volume by 5% and toggle mute.
#!/bin/bash
inc() {
playback_input=$(pactl list sink-inputs short | awk '{print $1}' | head -1)
pactl set-sink-input-volume "$playback_input" +5%
}
dec() {
playback_input=$(pactl list sink-inputs short | awk '{print $1}' | head -1)
pactl set-sink-input-volume "$playback_input" -5%
}
mute() {
playback_input=$(pactl list sink-inputs short | awk '{print $1}' | head -1)
pactl set-sink-input-mute "$playback_input" toggle
}
Related videos on Youtube
![9mjb](https://i.stack.imgur.com/CnddG.jpg?s=256&g=1)
9mjb
I'm more of a unix/Linux admin than a programmer. I code in C, Perl, and I want to do more python and lisp. I agree that lisp too complicated to be practical, but the syntax is so flat and lists are so simple that a subset of Common-Lisp appeals to me.
Updated on September 18, 2022Comments
-
9mjb almost 2 years
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
-
Jeff Schaller over 6 yearsThis is possibly useful technical information that does not address the question at all.
-
äxl over 6 yearsWhy not? The question only says "maybe amixer or pactl".
-
Jeff Schaller over 6 yearsIt 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! -
mivk almost 3 years@JeffSchaller : I feel that it not only exactly addresses the problem, but also that the
pa_volume
utility it links to is indeed by far the best solution to this problem. And I have searched a long time... -
Jeff Schaller almost 3 yearsMy point is that this question asks "how do I change the volume for just one application", and I don't see any steps in this Answer yet that demonstrate how to do that.