From 18dd99d79808073a2a2b978cc05f2aa4320c11d6 Mon Sep 17 00:00:00 2001 From: Hermes Date: Wed, 20 May 2026 14:28:40 -0400 Subject: [PATCH] feat: add custom/disk-monitor waybar module with color-coded disk usage --- waybar/.config/waybar/config.jsonc | 1 + waybar/.config/waybar/modules.json | 7 +++++ waybar/.config/waybar/scripts/disk-monitor.sh | 29 +++++++++++++++++++ 3 files changed, 37 insertions(+) create mode 100755 waybar/.config/waybar/scripts/disk-monitor.sh diff --git a/waybar/.config/waybar/config.jsonc b/waybar/.config/waybar/config.jsonc index 22cf676..ed264d3 100644 --- a/waybar/.config/waybar/config.jsonc +++ b/waybar/.config/waybar/config.jsonc @@ -25,6 +25,7 @@ "modules-right": [ "group/hardware", + "custom/disk-monitor", "pulseaudio", "bluetooth", "network", diff --git a/waybar/.config/waybar/modules.json b/waybar/.config/waybar/modules.json index 80d301e..dcc41b8 100644 --- a/waybar/.config/waybar/modules.json +++ b/waybar/.config/waybar/modules.json @@ -88,6 +88,13 @@ "path": "/", "on-click": "kitty btop" }, + + // disk monitor (standalone, color-coded) + "custom/disk-monitor": { + "exec": "$HOME/.config/waybar/scripts/disk-monitor.sh --waybar", + "return-type": "json", + "interval": 60 + }, // memory "memory": { diff --git a/waybar/.config/waybar/scripts/disk-monitor.sh b/waybar/.config/waybar/scripts/disk-monitor.sh new file mode 100755 index 0000000..51a2a82 --- /dev/null +++ b/waybar/.config/waybar/scripts/disk-monitor.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +# disk-monitor.sh -- Waybar disk usage monitor +# Outputs JSON for custom/disk-monitor module +# Class: "good" (<80%), "warning" (80-90%), "critical" (>90%) + +set -euo pipefail + +# Target partition (default: root) +TARGET="${1:-/}" + +# Get disk usage percentage (strip % sign) +USAGE=$(df --output=pcent "$TARGET" | tail -1 | tr -d '% ') + +# Determine icon and CSS class based on usage thresholds +if [ "$USAGE" -ge 90 ]; then + CLASS="critical" + TOOLTIP="Disk $TARGET at ${USAGE}% - CRITICAL" +elif [ "$USAGE" -ge 80 ]; then + CLASS="warning" + TOOLTIP="Disk $TARGET at ${USAGE}% - Warning" +else + CLASS="good" + TOOLTIP="Disk $TARGET at ${USAGE}%" +fi + +# Output JSON for waybar +printf '{"text": " \uf4be %s%% ", "class": "%s", "alt": "%s", "tooltip": "%s"}\n' \ + "$USAGE" "$CLASS" "disk-$CLASS" "$TOOLTIP"