Files
configs/.config/waybar/scripts/check-mount.sh
2026-04-15 20:27:52 +02:00

17 lines
617 B
Bash
Executable File

#!/usr/bin/bash
# Usage: check-mount.sh <mountpoint> <label>
# Outputs Waybar custom module JSON
MOUNT="$1"
LABEL="$2"
ICON_MOUNT="󰋊"
ICON_DOWN=""
if mountpoint -q "$MOUNT"; then
read -r used avail pcent <<< "$(df -h --output=used,avail,pcent "$MOUNT" | tail -1)"
printf '{"text": "%s %s %s/%s (%s)", "tooltip": "%s mounted — used: %s, free: %s (%s)", "class": "mounted"}\n' \
"$ICON_MOUNT" "$LABEL" "$used" "$avail" "$pcent" "$MOUNT" "$used" "$avail" "$pcent"
else
printf '{"text": "%s %s N/A", "tooltip": "%s is NOT mounted", "class": "unmounted"}\n' "$ICON_DOWN" "$LABEL" "$MOUNT"
fi