From d2b62c9d6f30a0ea88b2a235cde120cd10ba332b Mon Sep 17 00:00:00 2001 From: Ryan Schanzenbacher Date: Sat, 11 Jul 2026 22:14:43 -0400 Subject: Sketchybar now, got tired of the battery issue --- .../sketchybar/bar-config/plugins/storage.sh | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 users/ryan/modules/sketchybar/bar-config/plugins/storage.sh (limited to 'users/ryan/modules/sketchybar/bar-config/plugins/storage.sh') diff --git a/users/ryan/modules/sketchybar/bar-config/plugins/storage.sh b/users/ryan/modules/sketchybar/bar-config/plugins/storage.sh new file mode 100755 index 0000000..b844bb5 --- /dev/null +++ b/users/ryan/modules/sketchybar/bar-config/plugins/storage.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +source "$CONFIG_DIR/colors.sh" +source "$CONFIG_DIR/icons.sh" + +CACHE="/tmp/sketchybar_${NAME}.txt" +case "$SENDER" in + mouse.entered) + [ -f "$CACHE" ] && sketchybar --set "$NAME.details" label="$(cat "$CACHE")" + sketchybar --set "$NAME" popup.drawing=on; exit 0 ;; + mouse.exited) + sketchybar --set "$NAME" popup.drawing=off; exit 0 ;; +esac + +# On APFS the real user usage lives on the Data volume; fall back to / +VOL="/System/Volumes/Data"; [ -d "$VOL" ] || VOL="/" + +DF="$(df -h "$VOL" | awk 'NR==2{gsub("%","",$5); print $2, $3, $4, $5}')" +set -- $DF; SIZE="$1"; USED="$2"; AVAIL="$3"; PCT="$4" +[ -z "$PCT" ] && exit 0 + +COLOR=$TEXT +if [ "$PCT" -ge 90 ]; then COLOR=$RED # custom-storage.critical +elif [ "$PCT" -ge 80 ]; then COLOR=$YELLOW # custom-storage.warning +fi + +sketchybar --set "$NAME" label="${PCT}% ${DISK}" label.color=$COLOR +printf '%s' "Disk · ${USED} used of ${SIZE} (${PCT}%) · ${AVAIL} free" > "$CACHE" -- cgit v1.3