Fix sketchybar disk usage showing incorrect percentage

Monitor /System/Volumes/Data instead of / since root is a read-only
APFS snapshot with minimal usage. Also fix inverted formula that was
calculating 100-used instead of just using the capacity value directly.
This commit is contained in:
2026-01-27 11:32:48 -08:00
parent 8e8b5f4304
commit 188d2befb0

View File

@@ -632,8 +632,9 @@ in
text = ''
#!/bin/bash
# df $5 can show free% on some APFS setups; calculate used% explicitly
DISK_USAGE=$(df -H / | grep -v Filesystem | awk '{gsub(/%/,"",$5); printf "%.0f%%", 100-$5}')
# Monitor /System/Volumes/Data which contains user data on APFS
# The root / is a read-only snapshot with minimal usage
DISK_USAGE=$(df -H /System/Volumes/Data | grep -v Filesystem | awk '{print $5}')
${pkgs.sketchybar}/bin/sketchybar --set $NAME label="$DISK_USAGE"
'';