refractor: move code to abstract.sh enable unique and central color palette and progress bar
This commit is contained in:
46
modules/audio.sh
Executable file
46
modules/audio.sh
Executable 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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
'
|
Reference in New Issue
Block a user