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.

36 lines
917 B
Bash
Executable File

[[ "$BLOCK_BUTTON" == 2 ]] && i3-sensible-terminal -e htop
top -bn1 | gawk -v LONG="$LONG" -v COLORS="$COLORS" -v BAR="${BAR[*]}" -v COLOR="${COLOR[*]}" -v BW="${BW[*]}" '
BEGIN {
split(BAR, bar, / /)
split(COLOR, color, / /)
split(BW, bw, / /)
interval = 100 / length(bar)
}
/^\%CPU/ { load = 100 - $8 }
END {
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
}
}
}
'