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 | |
| 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')
| -rw-r--r-- | dot_config/waybar/config.jsonc | 25 | ||||
| -rwxr-xr-x | dot_config/waybar/executable_memory-status.sh | 29 | ||||
| -rwxr-xr-x | dot_config/waybar/executable_wifi-status.sh | 10 |
3 files changed, 60 insertions, 4 deletions
diff --git a/dot_config/waybar/config.jsonc b/dot_config/waybar/config.jsonc index b4d03ab..585fa38 100644 --- a/dot_config/waybar/config.jsonc +++ b/dot_config/waybar/config.jsonc @@ -27,19 +27,40 @@ "cpu": { "format": "CPU {usage}%", + "format-low": "CPU <span color='#b8bb26'>{usage}%</span>", + "format-medium": "CPU <span color='#fabd2f'>{usage}%</span>", + "format-high": "CPU <span color='#fe8019'>{usage}%</span>", + "format-critical": "CPU <span color='#fb4934'>{usage}%</span>", + "states": { + "low": 0, + "medium": 30, + "high": 60, + "critical": 80, + }, "interval": 5, "tooltip": false, }, "custom/memory": { - "exec": "awk '/^MemTotal:/{t=$2} /^MemAvailable:/{a=$2} END{u=t-a; printf \"MEM %.1fG (%d%%) / %.1fG (%d%%)\\n\", u/1048576, u*100/t, a/1048576, a*100/t}' /proc/meminfo", + "exec": "~/.config/waybar/memory-status.sh", + "return-type": "json", "interval": 10, "tooltip": false, }, "temperature": { "format": "{temperatureC}°C", - "critical-threshold": 80, + "format-cool": "<span color='#b8bb26'>{temperatureC}°C</span>", + "format-warm": "<span color='#fabd2f'>{temperatureC}°C</span>", + "format-hot": "<span color='#fe8019'>{temperatureC}°C</span>", + "format-scorching": "<span color='#fb4934'>{temperatureC}°C</span>", + "states": { + "cool": 0, + "warm": 50, + "hot": 65, + "scorching": 80, + }, + "interval": 5, }, "custom/wifi": { 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 diff --git a/dot_config/waybar/executable_wifi-status.sh b/dot_config/waybar/executable_wifi-status.sh index b93a28c..e69e5bb 100755 --- a/dot_config/waybar/executable_wifi-status.sh +++ b/dot_config/waybar/executable_wifi-status.sh @@ -22,6 +22,12 @@ rssi=$(printf '%s\n' "$out" | sed -n 's/^[[:space:]]*\*\{0,1\}[[:space:]]*AverageRSSI[[:space:]]\{2,\}//p' | awk '{print $1; exit}') pct=$(awk -v r="${rssi:-0}" 'BEGIN{p=2*(r+100); if(p>100)p=100; if(p<0)p=0; printf "%d",p}') +color=$(awk -v p="$pct" 'BEGIN{ + if (p < 20) print "#fb4934" + else if (p < 40) print "#fe8019" + else if (p < 70) print "#fabd2f" + else print "#b8bb26" +}') -printf '{"text":"%s %s%%","class":"up","tooltip":"%s · %s dBm"}\n' \ - "$ssid" "$pct" "$iface" "$rssi" +printf '{"text":"%s <span color=\x27%s\x27>%s%%</span>","class":"up","tooltip":"%s · %s dBm"}\n' \ + "$ssid" "$color" "$pct" "$iface" "$rssi" |
