This repository has been archived on 2019-02-28. You can view files and clone it, but cannot push or open issues or pull requests.

47 lines
1.3 KiB
Bash

[[ "$BLOCK_INSTANCE" =~ "mic" ]] && DEV="Capture" || DEV="Master"
[[ "$BLOCK_BUTTON" == 2 ]] && pavucontrol &
[[ "$BLOCK_BUTTON" == 3 ]] && amixer set $DEV toggle &> /dev/null
amixer get $DEV | gawk -v BAR="${BAR[*]}" -v BW="${BW[*]}" -v COLORS="$COLORS" -v COLOR="${COLOR[*]}" -v LONG="$LONG" '
BEGIN {
split(BAR, bar, / /)
split(COLOR, color, / /)
split(BW, bw, / /)
interval = 100 / length(bar)
}
match($0, /\[([0-9]+)\%\] \[(on|off)\]/, matches) {
load = matches[1]
}
END {
if (matches[2] == "off") {
print("off\n")
print("X\n")
print("#CCCCCC")
} else {
if (LONG) {
printf("%d%\n%d\n", load, load)
} else {
for (i in bar) {
if (load <= i * interval) {
printf("%s\n%s\n", bar[i], bar[i])
break
}
}
}
for (i in bw) {
if (load <= i * interval) {
if (COLORS) {
printf("%s\n", color[i])
} else {
printf("%s\n", bw[i])
}
break
}
}
}
}
'