|
|
|
@ -0,0 +1,129 @@ |
|
|
|
|
#!/bin/sh |
|
|
|
|
|
|
|
|
|
set -e |
|
|
|
|
|
|
|
|
|
while [ $# -gt 0 ] ; do |
|
|
|
|
case "$1" in |
|
|
|
|
"--newline") |
|
|
|
|
newline=1 |
|
|
|
|
;; |
|
|
|
|
"--unit") |
|
|
|
|
unitsymbol="%" |
|
|
|
|
;; |
|
|
|
|
"--no-value") |
|
|
|
|
no_value=1 |
|
|
|
|
;; |
|
|
|
|
"--icon") |
|
|
|
|
case $2 in |
|
|
|
|
"ascii"|""|"--"*) |
|
|
|
|
case "$2" in |
|
|
|
|
"--"*|"") |
|
|
|
|
: # skip if it's a parameter or is empty |
|
|
|
|
;; |
|
|
|
|
*) |
|
|
|
|
shift |
|
|
|
|
;; |
|
|
|
|
esac |
|
|
|
|
iconize=1 |
|
|
|
|
iconlvl0="[----]" |
|
|
|
|
iconlvl1="[#---]" |
|
|
|
|
iconlvl2="[##--]" |
|
|
|
|
iconlvl3="[###-]" |
|
|
|
|
iconlvl4="[####]" |
|
|
|
|
;; |
|
|
|
|
"nerd") |
|
|
|
|
shift |
|
|
|
|
iconize=1 |
|
|
|
|
icon_nerd=1 |
|
|
|
|
iconlvl0= |
|
|
|
|
iconlvl1= |
|
|
|
|
iconlvl2= |
|
|
|
|
iconlvl3= |
|
|
|
|
iconmute= |
|
|
|
|
;; |
|
|
|
|
*) |
|
|
|
|
printf "Icon coding not supported. Aborting...\n" |
|
|
|
|
exit 1 |
|
|
|
|
;; |
|
|
|
|
esac |
|
|
|
|
;; |
|
|
|
|
"--icon-mute") |
|
|
|
|
iconize_mute=1 |
|
|
|
|
;; |
|
|
|
|
*) |
|
|
|
|
printf "Parameter not recognized. Aborting...\n" |
|
|
|
|
exit 1 |
|
|
|
|
;; |
|
|
|
|
esac |
|
|
|
|
shift |
|
|
|
|
done |
|
|
|
|
|
|
|
|
|
DEFAULT_SINK_NAME="" |
|
|
|
|
DEFAULT_SOURCE_NAME="" |
|
|
|
|
|
|
|
|
|
lvl="" |
|
|
|
|
|
|
|
|
|
__lvlbar(){ |
|
|
|
|
if [ "$iconize_mute" = 1 ] && [ "$2" = "muted" ]; then |
|
|
|
|
icon="$iconmute" |
|
|
|
|
else |
|
|
|
|
if [ "$icon_nerd" = 1 ]; then |
|
|
|
|
if [ "$1" -le 0 ]; then |
|
|
|
|
icon="${iconlvl0}" |
|
|
|
|
elif [ "$1" -le 30 ]; then |
|
|
|
|
icon="${iconlvl1}" |
|
|
|
|
elif [ "$1" -le 85 ]; then |
|
|
|
|
icon="${iconlvl2}" |
|
|
|
|
elif [ "$1" -le 100 ]; then |
|
|
|
|
icon="${iconlvl3}" |
|
|
|
|
else |
|
|
|
|
icon="${iconlvl4}" |
|
|
|
|
fi |
|
|
|
|
else |
|
|
|
|
if [ "$1" -le 5 ]; then |
|
|
|
|
icon="${iconlvl0}" |
|
|
|
|
elif [ "$1" -le 15 ]; then |
|
|
|
|
icon="${iconlvl0}" |
|
|
|
|
elif [ "$1" -le 35 ]; then |
|
|
|
|
icon="${iconlvl1}" |
|
|
|
|
elif [ "$1" -le 65 ]; then |
|
|
|
|
icon="${iconlvl2}" |
|
|
|
|
elif [ "$1" -le 97 ]; then |
|
|
|
|
icon="${iconlvl3}" |
|
|
|
|
else |
|
|
|
|
icon="${iconlvl4}" |
|
|
|
|
fi |
|
|
|
|
fi |
|
|
|
|
fi |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
__send(){ |
|
|
|
|
case $1 in |
|
|
|
|
DEFAULT_SINK_NAME) |
|
|
|
|
DEFAULT_SINK_NAME="$2" |
|
|
|
|
;; |
|
|
|
|
DEFAULT_SOURCE_NAME) |
|
|
|
|
DEFAULT_SOURCE_NAME="$2" |
|
|
|
|
;; |
|
|
|
|
SINKVOL) |
|
|
|
|
[ "$no_value" = 1 ] && : || lvl=$3 |
|
|
|
|
[ "$iconize" = 1 ] && __lvlbar "$3" "$2" || : |
|
|
|
|
;; |
|
|
|
|
*) |
|
|
|
|
: |
|
|
|
|
;; |
|
|
|
|
esac |
|
|
|
|
|
|
|
|
|
printf ":SET audi %b%s%s%s%s%b%s" "${color}" "${icon}" "${status}" "${lvl}" "${unitsymbol}" "${colend}${colbgend}" "${sep}" |
|
|
|
|
|
|
|
|
|
[ "$newline" = 1 ] && printf "\n" || : |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if [ -t 0 ]; then |
|
|
|
|
printf "running interactivelly" |
|
|
|
|
else |
|
|
|
|
while read -r line ; do |
|
|
|
|
__send $line |
|
|
|
|
done |
|
|
|
|
fi |