summaryrefslogtreecommitdiffstats
path: root/.local/bin
diff options
context:
space:
mode:
authorLuke Smith <luke@lukesmith.xyz>2020-07-02 15:32:36 -0400
committerLuke Smith <luke@lukesmith.xyz>2020-07-02 15:32:36 -0400
commit00534b7ccaf410a85a11301c2c0ffdfae5bd8a5e (patch)
treef9794cb77a26853f40cd6e38139e7ca4251cfbb2 /.local/bin
parentf26304c59bd7f79b43b34770dcd4a759826f9d89 (diff)
downloadeibhear-00534b7ccaf410a85a11301c2c0ffdfae5bd8a5e.tar.gz
eibhear-00534b7ccaf410a85a11301c2c0ffdfae5bd8a5e.tar.zst
eibhear-00534b7ccaf410a85a11301c2c0ffdfae5bd8a5e.zip
posix fixes
Diffstat (limited to '.local/bin')
-rwxr-xr-x.local/bin/statusbar/cpubars31
1 files changed, 15 insertions, 16 deletions
diff --git a/.local/bin/statusbar/cpubars b/.local/bin/statusbar/cpubars
index d960727..297424e 100755
--- a/.local/bin/statusbar/cpubars
+++ b/.local/bin/statusbar/cpubars
@@ -10,7 +10,7 @@ cache=/tmp/cpubarscache
case $BLOCK_BUTTON in
2) setsid -f "$TERMINAL" -e htop ;;
- 3) notify-send "🪨 CPU load module" "Each bar represents
+ 3) notify-send "🪨 CPU load module" "Each bar represents
one CPU core";;
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac
@@ -19,27 +19,26 @@ esac
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"
old=$(cat "$cache")
-echo -n "🪨"
-echo "$stats" | while read row; do
+printf "🪨"
+echo "$stats" | while read -r row; do
id=${row%% *}
rest=${row#* }
total=${rest%% *}
idle=${rest##* }
- case "$(echo "$old" | awk '{if ($1 == id)
+ case "$(echo "$old" | awk '{if ($1 == id)
printf "%d\n", (1 - (idle - $3) / (total - $2))*100 /12.5}' \
- id=$id total=$total idle=$idle)" in
+ id="$id" total="$total" idle="$idle")" in
- "0") echo -n "▁";;
- "1") echo -n "▂";;
- "2") echo -n "▃";;
- "3") echo -n "▄";;
- "4") echo -n "▅";;
- "5") echo -n "▆";;
- "6") echo -n "▇";;
- "7") echo -n "█";;
- "8") echo -n "█";;
+ "0") printf "▁";;
+ "1") printf "▂";;
+ "2") printf "▃";;
+ "3") printf "▄";;
+ "4") printf "▅";;
+ "5") printf "▆";;
+ "6") printf "▇";;
+ "7") printf "█";;
+ "8") printf "█";;
esac
-done
-echo ""
+done; printf "\\n"
echo "$stats" > "$cache"