diff options
| author | 2026-04-21 01:24:42 +0100 | |
|---|---|---|
| committer | 2026-04-21 01:24:42 +0100 | |
| commit | 88906113038c1b4986cfc3bf6afc0fb35c5e4127 (patch) | |
| tree | 8455ae8c64fe09f0a35178b0d0a60cf525d32f77 /dot_config/waybar/executable_memory-status.sh | |
| parent | 0b0dcd8013b98fb1ac5e57921f79c25df952f262 (diff) | |
| download | dotfiles-88906113038c1b4986cfc3bf6afc0fb35c5e4127.tar.gz dotfiles-88906113038c1b4986cfc3bf6afc0fb35c5e4127.tar.bz2 dotfiles-88906113038c1b4986cfc3bf6afc0fb35c5e4127.zip | |
waybar: heat-colour CPU/memory/wifi %/temperature values via pango
Diffstat (limited to 'dot_config/waybar/executable_memory-status.sh')
| -rwxr-xr-x | dot_config/waybar/executable_memory-status.sh | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/dot_config/waybar/executable_memory-status.sh b/dot_config/waybar/executable_memory-status.sh new file mode 100755 index 0000000..c68f5a4 --- /dev/null +++ b/dot_config/waybar/executable_memory-status.sh @@ -0,0 +1,29 @@ +#!/bin/sh +# Emit waybar JSON with memory usage. Used% uses a heat scale (green → red), +# available% uses the inverse (red → green). Values embedded via Pango span. +set -eu + +awk ' +function heat(p) { + if (p < 30) return "#b8bb26" + if (p < 60) return "#fabd2f" + if (p < 80) return "#fe8019" + return "#fb4934" +} +function cool(p) { + if (p < 20) return "#fb4934" + if (p < 40) return "#fe8019" + if (p < 70) return "#fabd2f" + return "#b8bb26" +} +/^MemTotal:/ { t = $2 } +/^MemAvailable:/ { a = $2 } +END { + u = t - a + up = u * 100 / t + ap = a * 100 / t + printf "{\"text\":\"MEM %.1fG (<span color=\x27%s\x27>%d%%</span>) / %.1fG (<span color=\x27%s\x27>%d%%</span>)\"}\n", \ + u / 1048576, heat(up), up, \ + a / 1048576, cool(ap), ap +} +' /proc/meminfo |
