dotfiles/bin/.bin/avol
Anthony Debucquoy 9eede5ef5f
First Commit
This is a first dotfiles config. I think I have a lot more to add tho...
2023-10-24 23:29:07 +02:00

27 lines
719 B
Bash
Executable File

#!/bin/bash
#
# Manage ALSA Master channel
test "$1" = "-h" && echo "usage `basename $0` [up|down|mute]" && exit 0
level() {
amixer get Master | sed -n 's/^.*\[\([0-9]\+%\).*$/\1/p' | uniq
}
state() {
amixer get Master | sed -n 's/^.*\[\(o[nf]\+\)]$/\1/p' | uniq
}
test $# -eq 0 && echo "`level` `state`" && exit 0
case $1 in
up) amixer set Master ${2:-5}%+ >/dev/null ||autoalsaconfamixer;;
down) amixer set Master ${2:-5}%- >/dev/null ||autoalsaconf;;
mute) amixer set Master toggle >/dev/null ||autoalsaconf;;
state|level) $1 ||autoalsaconf;;
set) amixer set Master $2% >/dev/null ||autoalsaconf;;
*) amixer set Master $1% >/dev/null ||autoalsaconf;;
esac