dotfiles/.config/waybar/modules/storage.sh
2020-04-29 13:33:26 +02:00

24 lines
388 B
Bash
Executable File

#!/bin/sh
mount="/"
warning=20
critical=10
df -h -P -l "$mount" | awk -v warning=$warning -v critical=$critical '
/\/.*/ {
text=$4
use=$5
exit 0
}
END {
class=""
gsub(/%$/,"",use)
if ((100 - use) < critical) {
class="critical"
} else if ((100 - use) < warning) {
class="warning"
}
print "{\"text\":\""text"\", \"percentage\":"use", \"class\":\""class"\"}"
}
'