diff options
author | awy <awy@awy.one> | 2025-07-30 19:42:26 +0300 |
---|---|---|
committer | awy <awy@awy.one> | 2025-07-30 19:42:26 +0300 |
commit | 6315ae646c2cf3885c5b401a92c922f643897aa2 (patch) | |
tree | 14de758f531665edf772a1158b3af80c2f06e49b | |
parent | bf852bc465bde8da594c2c2b4ee831bf352841c0 (diff) | |
download | hyprdots-6315ae646c2cf3885c5b401a92c922f643897aa2.tar.gz |
memory module
-rw-r--r-- | .config/waybar/config.json | 3 | ||||
-rw-r--r-- | .config/waybar/style.css | 12 | ||||
-rwxr-xr-x | .local/bin/statusbar/sb-memory | 21 |
3 files changed, 34 insertions, 2 deletions
diff --git a/.config/waybar/config.json b/.config/waybar/config.json index 8d32834..fad14d4 100644 --- a/.config/waybar/config.json +++ b/.config/waybar/config.json @@ -129,7 +129,8 @@ "on-click": "BLOCK_BUTTON=1 sb-memory", "on-click-right": "BLOCK_BUTTON=3 sb-memory", "on-click-middle": "BLOCK_BUTTON=2 sb-memory", - "on-click-backward": "BLOCK_BUTTON=8 sb-memory" + "on-click-backward": "BLOCK_BUTTON=8 sb-memory", + "return-type": "json" }, "custom/doppler" : { diff --git a/.config/waybar/style.css b/.config/waybar/style.css index 80b90d5..d429eba 100644 --- a/.config/waybar/style.css +++ b/.config/waybar/style.css @@ -89,6 +89,18 @@ window#waybar { padding-right: 10px; } +#custom-memory.high { + color: @red; +} + +#custom-memory.mid { + color: @yellow; +} + +#custom-memory.low { + color: @green; +} + #custom-forecast { padding-right: 10px; } diff --git a/.local/bin/statusbar/sb-memory b/.local/bin/statusbar/sb-memory index a37f1ca..09f23bf 100755 --- a/.local/bin/statusbar/sb-memory +++ b/.local/bin/statusbar/sb-memory @@ -9,4 +9,23 @@ case $BLOCK_BUTTON in 8) setsid -f "$TERMINAL" -e "$EDITOR" "$0" >/dev/null 2>&1 ;; esac -free --mebi | sed -n '2{p;q}' | awk '{printf ("🧠%sMB\n", ($3))}' +used=$(free --mebi | sed -n '2{p;q}' | awk '{print $3}') +total=$(free --mebi | sed -n '2{p;q}' | awk '{print $2}') + +usage_percentage=$((100 * used / total)) + +case 1 in + $((usage_percentage >= 87)) ) icon="█ "; class="high" ;; + $((usage_percentage >= 70)) ) icon="▇ "; class="high" ;; + $((usage_percentage >= 62)) ) icon="▆ "; class="mid" ;; + $((usage_percentage >= 50)) ) icon="▅ "; class="mid" ;; + $((usage_percentage >= 37)) ) icon="▄ "; class="mid" ;; + $((usage_percentage >= 25)) ) icon="▃ "; class="low" ;; + $((usage_percentage >= 12)) ) icon="▂ "; class="low" ;; + $((usage_percentage >= 0)) ) icon="▁ "; class="low" ;; + * ) echo unavailable && exit ;; +esac + +output="$icon${used}MB" + +printf '{"text": "%s", "class": "%s" }' "$output" "$class" |