2016-10-19 12:40:02 -07:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2016-11-10 12:31:35 -08:00
|
|
|
if (($# == 0)); then
|
2016-10-22 05:04:50 -07:00
|
|
|
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
|
|
|
|
|
2016-11-10 12:31:35 -08:00
|
|
|
case $1 in
|
|
|
|
[0-9]*) amixer set Master $1 ;;
|
2017-01-03 00:44:35 -08:00
|
|
|
[+-]) amixer set Master 5%$1 ;;
|
2016-11-10 12:31:35 -08:00
|
|
|
*mute) amixer set Master $1 ;;
|
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
|
|
|
|
|
2017-05-11 12:43:26 -07:00
|
|
|
# community/xosd
|
|
|
|
if command -v osd_cat >/dev/null; then
|
|
|
|
killall -9 -q osd_cat &>/dev/null
|
|
|
|
osd_cat --font="10x20" --delay=2 --color=white --align=center --pos=bottom --barmode=percentage --percentage $($0) &
|
|
|
|
fi
|
2016-11-10 12:31:35 -08:00
|
|
|
|
2016-10-19 12:40:02 -07:00
|
|
|
# Report to lemonbar, if active
|
2016-11-10 12:31:35 -08:00
|
|
|
$HOME/.config/panel/panel-notify :volume
|