refractor: move code to abstract.sh enable unique and central color palette and progress bar

This commit is contained in:
koksnuss
2018-08-10 15:13:31 +02:00
parent 11f963804e
commit 451dd44eac
19 changed files with 325 additions and 403 deletions

46
modules/audio.sh Executable file
View File

@ -0,0 +1,46 @@
[[ "$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
}
}
}
}
'