1
0
Fork 0
dotfiles/files/bin/volume-control

49 lines
1.2 KiB
Plaintext
Raw Normal View History

2018-10-31 17:11:04 +00:00
#!/usr/bin/env bash
# You can call this script like this:
# $ ./volumeControl.sh up
# $ ./volumeControl.sh down
# $ ./volumeControl.sh mute
# Script modified from these wonderful people:
# https://github.com/dastorm/volume-notification-dunst/blob/master/volume.sh
# https://gist.github.com/sebastiencs/5d7227f388d93374cebdf72e783fbd6a
function get_volume {
amixer get Master | grep '%' | head -n 1 | cut -d '[' -f 2 | cut -d '%' -f 1
}
function is_mute {
amixer get Master | grep '%' | grep -oE '[^ ]+$' | grep off > /dev/null
}
function send_notification {
iconSound="notification-audio-volume-high"
iconMuted="notification-audio-volume-muted"
if is_mute ; then
echo 0 >"$XDG_RUNTIME_DIR/wobpipe"
2018-10-31 17:11:04 +00:00
else
echo "$(get_volume)" >"$XDG_RUNTIME_DIR/wobpipe"
2018-10-31 17:11:04 +00:00
fi
}
case $1 in
up)
# set the volume on (if it was muted)
amixer -D pulse set Master on > /dev/null
# up the volume (+ 5%)
amixer -D pulse sset Master 5%+ > /dev/null
send_notification
;;
down)
amixer -D pulse set Master on > /dev/null
amixer -D pulse sset Master 5%- > /dev/null
send_notification
;;
mute)
# toggle mute
amixer -D pulse set Master 1+ toggle > /dev/null
send_notification
;;
esac