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 6,132 times
6
2 Answers
1
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
- 17,371