i3blocks/cpu_load.sh (view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
#!/bin/sh load="$(cut -d ' ' -f1 /proc/loadavg)" cpus="$(nproc)" # full text echo "$load" # short text echo "$load" # color if load is too high awk -v cpus=$cpus -v cpuload=$load ' BEGIN { if (cpus <= cpuload) { print "#FF0000"; exit 33; } } '