46 lines
1.0 KiB
Plaintext
46 lines
1.0 KiB
Plaintext
|
#!/usr/bin/env bash
|
||
|
export LC_ALL=POSIX LANG=POSIX; . "${HOME}/.owl4ce_var"
|
||
|
|
||
|
type -p amixer &>/dev/null || exec echo 'Install alsa-utils!'
|
||
|
|
||
|
VOLUME="$(amixer get Master | grep -oP '\[\K[^%\]]+' | sed 1q)"
|
||
|
|
||
|
icon()
|
||
|
{
|
||
|
if [ "$VOLUME" -eq 0 ]; then
|
||
|
icon=''
|
||
|
elif [ "$VOLUME" -lt 30 ]; then
|
||
|
icon=''
|
||
|
elif [ "$VOLUME" -lt 70 ]; then
|
||
|
icon=''
|
||
|
else
|
||
|
icon=''
|
||
|
fi
|
||
|
exec echo "$icon"
|
||
|
}
|
||
|
|
||
|
case ${1} in
|
||
|
percent) if amixer get Master | grep -Fqo 'off'; then
|
||
|
exec echo 'Muted'
|
||
|
else
|
||
|
exec echo "${VOLUME}%"
|
||
|
fi
|
||
|
;;
|
||
|
icon) if amixer get Master | grep -Fqo 'off'; then
|
||
|
exec echo ""
|
||
|
else
|
||
|
icon
|
||
|
fi
|
||
|
;;
|
||
|
up) amixer set Master on -q
|
||
|
exec amixer sset Master "${AUDIO_STEPS:-5}%+" -q
|
||
|
;;
|
||
|
down) amixer set Master on -q
|
||
|
exec amixer sset Master "${AUDIO_STEPS:-5}%-" -q
|
||
|
;;
|
||
|
mute) exec amixer set Master 1+ toggle -q
|
||
|
;;
|
||
|
esac
|
||
|
|
||
|
exit ${?}
|