config_sway/bin/volume

40 lines
637 B
Bash
Executable file

#!/bin/bash
source $HOME/.config/sway/bin/helpers
SINK=$(pacmd list-sinks | grep "* index" | grep -oE '[0-9]*')
APP="pavucontrol"
## helpers
function _toggle() {
a=$1
if [ $(pgrep $a) ]; then
killall $a
else
$a &> /dev/null &
fi
}
## main
if [ -z "$SINK" ]; then
_log VOLUME ERROR args: $*
exit 1
fi
case $1 in
d*)
pactl set-sink-volume $SINK -5%
;;
i*)
pactl set-sink-volume $SINK +5%
;;
m*)
pactl set-sink-mute $SINK toggle
;;
gui)
_check_app $APP
_toggle $APP
;;
*)
echo "invalid command: \"$1\""
echo "arguments: [decrease|increase|mute|gui]"
;;
esac