From f5a9256e3287bb4e1e3f630621ae9975b1f82e3f Mon Sep 17 00:00:00 2001
From: Luca Bilke <luca@bil.ke>
Date: Mon, 23 Sep 2024 14:58:35 +0200
Subject: [PATCH] sb-memory: replace output with bars

---
 .local/libexec/statusbar/sb-memory | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/.local/libexec/statusbar/sb-memory b/.local/libexec/statusbar/sb-memory
index b5cb3c78..fcc23165 100755
--- a/.local/libexec/statusbar/sb-memory
+++ b/.local/libexec/statusbar/sb-memory
@@ -1,5 +1,14 @@
 #!/bin/sh
 . "colors"
 
-printf "%b" "󰘚 "
-free -m | awk 'NR==2 { printf ("%2.2fG/%2.2fG\n", ($3 / 1024), ($2 / 1024)) }'
+case "$(free -m | awk 'NR==2 { printf "%d", ($3 / $2) * 10 }')" in
+    0 | 1) color="$fggreen" bar="▁" ;;
+    2) color="$fggreen" bar="▂" ;;
+    3 | 4) color="$fggreen" bar="▃" ;;
+    5) color="$fgorange" bar="▄" ;;
+    6 | 7) color="$fgorange" bar="▅" ;;
+    8) color="$fgred" bar="▆" ;;
+    *) color="$fgred" bar="▇" ;;
+esac
+
+printf "󰘚 <span %s %s>%s</span>" "${bggray}" "${color}" "$bar"