helm/os/arch/bin/volume

25 lines
574 B
Plaintext
Raw Normal View History

2016-10-19 12:40:02 -07:00
#!/usr/bin/env bash
2016-11-02 16:58:47 -07:00
if [[ $# = 0 ]]
2016-10-19 12:40:02 -07:00
then
data=$(amixer get Master)
vol=$(echo "$data" | sed -n 's/^.*\[\([0-9]\+\)%.*$/\1/p' | uniq)
state=$(echo "$data" | grep '\[on\]')
[[ $state ]] && echo $vol || echo 0
2016-10-19 12:58:30 -07:00
exit
2016-10-19 12:40:02 -07:00
fi
COMMAND=$1
case "$COMMAND" in
2016-10-19 12:58:30 -07:00
[0-9]*) amixer set Master $COMMAND ;;
[+-]) amixer set Master 10%$COMMAND ;;
*mute) amixer set Master $COMMAND ;;
2016-10-20 15:09:26 -07:00
toggle) amixer set Master toggle ;;
2016-10-19 12:58:30 -07:00
*) >&2 echo "Invalid command"
2016-10-19 12:40:02 -07:00
exit 1
;;
esac
# Report to lemonbar, if active
2016-11-02 16:58:47 -07:00
~/.config/panel/panel_update.sh volume