diff options
author | Joe <bousset.rudy@gmail.com> | 2022-08-17 17:59:31 +0200 |
---|---|---|
committer | Joe <bousset.rudy@gmail.com> | 2022-08-17 17:59:31 +0200 |
commit | 3c886473d7786020619958ad5900549d7e85b759 (patch) | |
tree | c5e24f074edacc9a3823bacdcabcdf7ea0ee65ef | |
parent | update (diff) | |
download | dotfiles-bsd-3c886473d7786020619958ad5900549d7e85b759.tar.gz dotfiles-bsd-3c886473d7786020619958ad5900549d7e85b759.tar.bz2 dotfiles-bsd-3c886473d7786020619958ad5900549d7e85b759.tar.xz dotfiles-bsd-3c886473d7786020619958ad5900549d7e85b759.tar.zst dotfiles-bsd-3c886473d7786020619958ad5900549d7e85b759.zip |
cool
-rwxr-xr-x | .local/bin/status/sb-cpu | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/.local/bin/status/sb-cpu b/.local/bin/status/sb-cpu index 2504428..3775864 100755 --- a/.local/bin/status/sb-cpu +++ b/.local/bin/status/sb-cpu @@ -1,20 +1,20 @@ #!/bin/sh ncpu=$(sysctl -n hw.ncpu) -ncpu=$((ncpu - 1)) -cpu="" +ncpu=$((ncpu + 1)) +topline=$((ncpu * 2 - 1)) + printf " " -w | head -n1 | awk '{print $8}' | cut -d',' -f1 -# for i in $(seq 0 $ncpu); do -# case $(sysctl -n dev.cpu.$i.cx_usage | cut -d'.' -f1 | awk '{printf "%d\n", $1 / 12.5}') in -# "0") printf "▁";; -# "1") printf "▂";; -# "2") printf "▃";; -# "3") printf "▄";; -# "4") printf "▅";; -# "5") printf "▆";; -# "6") printf "▇";; -# "7") printf "█";; -# "8") printf "█";; -# esac; -# done +for i in $(top -P -d 2 -s 0.2 | grep '^CPU' | sed -n ${ncpu},${topline}p | rev | cut -d' ' -f2 | rev | cut -d'.' -f1 | awk '{print (100 - $1)}'); do + case $(echo $i / 12.5 | bc) in + "0") printf "▁";; + "1") printf "▂";; + "2") printf "▃";; + "3") printf "▄";; + "4") printf "▅";; + "5") printf "▆";; + "6") printf "▇";; + "7") printf "█";; + "8") printf "█";; + esac; +done |