summaryrefslogtreecommitdiff
path: root/scripts/.local/bin/sb-cpubars
diff options
context:
space:
mode:
authorivan-boikov <ik.boikov.public@protonmail.com>2024-01-13 20:24:30 +0100
committerivan-boikov <ik.boikov.public@protonmail.com>2024-01-13 20:24:30 +0100
commit957dced5d85705e1ae65ca16eb902bd10d67b3e0 (patch)
treef190e8e68ab7088b85279959d8ea482b88c72cbb /scripts/.local/bin/sb-cpubars
parentc09234bb6e65868ebe83cbf91da83356ee0a2c70 (diff)
1
Diffstat (limited to 'scripts/.local/bin/sb-cpubars')
-rwxr-xr-xscripts/.local/bin/sb-cpubars4
1 files changed, 3 insertions, 1 deletions
diff --git a/scripts/.local/bin/sb-cpubars b/scripts/.local/bin/sb-cpubars
index 64cf8b0..82567a3 100755
--- a/scripts/.local/bin/sb-cpubars
+++ b/scripts/.local/bin/sb-cpubars
@@ -5,7 +5,7 @@ cache="$XDG_CACHE_HOME/cpubarscache"
# id total idle
stats=$(awk '/cpu[0-9]+/ {printf "%d %d %d\n", substr($1,4), ($2 + $3 + $4 + $5), $5 }' /proc/stat)
-[ ! -f $cache ] && echo "$stats" > "$cache"
+[ ! -f "$cache" ] && echo "$stats" > "$cache"
old=$(cat "$cache")
printf ""
echo "$stats" | while read -r row; do
@@ -18,6 +18,7 @@ echo "$stats" | while read -r row; do
printf "%d\n", (1 - (idle - $3) / (total - $2))*100 /12.5}' \
id="$id" total="$total" idle="$idle")" in
+ # these are called "block elements"
"0") printf "▁";;
"1") printf "▂";;
"2") printf "▃";;
@@ -27,6 +28,7 @@ echo "$stats" | while read -r row; do
"6") printf "▇";;
"7") printf "█";;
"8") printf "█";;
+ *) printf " ";;
esac
done; printf "\\n"
echo "$stats" > "$cache"