Skip to content

Instantly share code, notes, and snippets.

@shrdlu68
Created April 4, 2019 13:49
Show Gist options
  • Save shrdlu68/1e7ecff6784c39c61d3cf24ba3a88fcb to your computer and use it in GitHub Desktop.
Save shrdlu68/1e7ecff6784c39c61d3cf24ba3a88fcb to your computer and use it in GitHub Desktop.
Control volume of active PulseAudio audio sink
#!/bin/bash
function get_active_sink ()
{
input=$(pactl list short sinks | awk '$7=="RUNNING" {print $2}')
echo -n "$input"
}
function mute_toggle ()
{
pactl set-sink-mute "$1" toggle
}
function volume_incf ()
{
pactl set-sink-volume "$1" +2%
}
function volume_decf ()
{
pactl set-sink-volume "$1" -2%
}
sink=$(get_active_sink)
case "$1" in
toggle)
mute_toggle "$sink"
;;
incf)
volume_incf "$sink"
;;
decf)
volume_decf "$sink"
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment