updated waybar disk usage component

This commit is contained in:
2025-07-14 13:15:24 -04:00
parent 54d1c15823
commit caeb108974

View File

@@ -112,26 +112,19 @@ in {
"custom/disk-icon" = { "custom/disk-icon" = {
exec = '' exec = ''
df /dev/disk/by-partlabel/disk-main-home /dev/disk/by-partlabel/disk-main-nix | awk ' df / | awk '
function format(size) { function format(size) {
if (size >= 1024) return sprintf("%.1fTB", size / 1024) if (size >= 1024) return sprintf("%.1fTB", size / 1024);
else return sprintf("%.1fGB", size) else return sprintf("%.1fGB", size)
} }
$6 == "/home" { $6 == "/" {
home_usage = $3 / 1024 / 1024 usage = $3 / 1024 / 1024;
home_total = $2 / 1024 / 1024 total = $2 / 1024 / 1024;
home_percent = $5 percent = $5;
sub(/%/,"",home_percent) sub(/%/, "", percent);
printf "{\"class\": \"disk-icon\", \"tooltip\": \"/: %s / %s\", \"percentage\": %s}\n", format(usage), format(total), percent
} }
$6 == "/nix" { ' | jq --unbuffered --compact-output
nix_usage = $3 / 1024 / 1024
nix_total = $2 / 1024 / 1024
nix_percent = $5
}
END {
printf "{\"class\": \"disk-icon\", \"tooltip\": \"/home: %s / %s\\n/nix: %s / %s\", \"percentage\": %s}\n",
format(home_usage), format(home_total), format(nix_usage), format(nix_total), home_percent
}' | jq --unbuffered --compact-output
''; '';
interval = 60; interval = 60;
return-type = "json"; return-type = "json";
@@ -298,6 +291,8 @@ in {
#workspaces button:hover { #workspaces button:hover {
border-radius: 8px; border-radius: 8px;
background: #${fg.lightest};
color: #${bg.darkest};
} }
#workspaces button.active { #workspaces button.active {