diff options
author | Joe <bousset.rudy@gmail.com> | 2022-08-18 10:04:18 +0200 |
---|---|---|
committer | Joe <bousset.rudy@gmail.com> | 2022-08-18 10:04:18 +0200 |
commit | 3e81f78c5cc9990cc0b7d63891c07e1330d353f2 (patch) | |
tree | 23cd8f1be9a13441ad220cfde48fca0d2725c1e8 | |
parent | perfect (diff) | |
download | dotfiles-bsd-3e81f78c5cc9990cc0b7d63891c07e1330d353f2.tar.gz dotfiles-bsd-3e81f78c5cc9990cc0b7d63891c07e1330d353f2.tar.bz2 dotfiles-bsd-3e81f78c5cc9990cc0b7d63891c07e1330d353f2.tar.xz dotfiles-bsd-3e81f78c5cc9990cc0b7d63891c07e1330d353f2.tar.zst dotfiles-bsd-3e81f78c5cc9990cc0b7d63891c07e1330d353f2.zip |
cleaner
-rwxr-xr-x | .local/bin/status/sb-cpu | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/.local/bin/status/sb-cpu b/.local/bin/status/sb-cpu index 3775864..3b68cf4 100755 --- a/.local/bin/status/sb-cpu +++ b/.local/bin/status/sb-cpu @@ -1,11 +1,15 @@ #!/bin/sh -ncpu=$(sysctl -n hw.ncpu) -ncpu=$((ncpu + 1)) -topline=$((ncpu * 2 - 1)) +ncpu_file="/tmp/ncpu" +if [ -f $ncpu_file ]; then + ncpu=$(cat $ncpu_file) +else + ncpu=$(sysctl -n hw.ncpu | tee $ncpu_file) +fi printf " " -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 +# for i in $(top -P -d 1 | sed -n 3,${topline}p | rev | cut -d' ' -f2 | rev | cut -d'.' -f1 | awk '{print (100 - $1)}'); do +for i in $(top -P -d 2 -s 0.2 | grep '^CPU' | tail -n$ncpu | sed '{s/% idle$//;s/.*[[:blank:]]//;s/\..*//;s/^/100 - /;}' | bc); do case $(echo $i / 12.5 | bc) in "0") printf "▁";; "1") printf "▂";; |