Is there a way to change individual application volumes from the terminal? I found a way to change the master volume which is amixer -D pulse sset Master 50% but I would like to be able to change volumes for individual applications like is possible in pavucontrol. My usage would be for scripting.
Asked
Active
Viewed 4,297 times
4
-
Depends on the application. Look into `man
` – Jacob Vlijm Feb 23 '15 at 07:03 -
I don't want to change the in application volume, I want to change the pulseaudio volume level for any application. For example, skype, which has no runtime parameters. – AkBKukU Feb 23 '15 at 15:08
2 Answers
4
I found the solution hidden in a comment on unix.stackexchange. Use pactl list sink-inputs to find your application's sink input number. Then use pactl set-sink-input-volume [sink number] [volume percent] to set the volume of your application.
-
This one is great. I can now fade out spotify with `for ((i=50;i<100;i+=1)); do; pactl set-sink-input-volume 28 $i%; sleep 0.05; done ` Just need to know how to get spotify sink in a more assuring way. – Błażej Michalik Jan 23 '16 at 01:23
-
I had used this command to make a script to use the pedals from an old driving wheel to control music playback volume. I put the script up [here](https://gist.github.com/AkBKukU/b1c4ac785f92579bbba0). Check out the function `getSink` to see a way to do it in a script. Not that the second line in it uses the variable $SINKAPP. you can substitute your process name here. – AkBKukU Feb 09 '16 at 18:21
0
This function easily sets the volume of any app.
function pacmd-set-app-volume() {
local player="$1"
local volume="$2"
firstPlayerSinkIndex="$(pacmd list-sink-inputs | awk '/index:|application.name |application.process.binary / {print $0};' | grep -iB 1 "$player" | awk '/index:/ {print $2; exit}')" # get specific app sink
[[ $firstPlayerSinkIndex ]] && pacmd set-sink-input-volume "$firstPlayerSinkIndex" "$((volume*65536/100))" # 100% → 65536
}
Could be added to .bashrc/.zshrc.
Usage:
pacmd-set-app-volume <loosly_app_name> <volume_percentage>
For e.g.:
pacmd-set-app-volume "MPV Media Player" 55 # Or "mpv" "75"
Pablo Bianchi
- 14,308
- 4
- 74
- 117