This repository has been archived on 2019-02-28. You can view files and clone it, but cannot push or open issues or pull requests.

50 lines
1.3 KiB
Bash
Executable File

[[ "$BLOCK_BUTTON" == 2 ]] && i3-sensible-terminal -e ranger
df | gawk -v BAR="${BAR[*]}" -v BW="${BW[*]}" -v COLORS="$COLORS" -v COLOR="${COLOR[*]}" -v LONG="$LONG" '
BEGIN {
split(BAR, bar, / /)
split(COLOR, color, / /)
split(BW, bw, / /)
interval = 100 / length(bar)
}
/\/$/ {
free_storage = $4 / 1024^2
load = int(gensub(/^([0-9]{1,3})%$/, "\\1", "g", $5))
}
END {
if (LONG) {
if (free_storage < 1) {
printf(" full \n")
printf("full\n")
exit 33
} else if (free_storage > 5) {
printf("%.1f G\n", free_storage)
printf("%dG\n", free_storage)
} else {
printf("%.0f M\n", free_storage / 1024)
printf("%dM\n", free_storage / 1024)
}
} else {
for (i in bar) {
if (load <= i * interval) {
printf("%s\n%s\n", bar[i], bar[i])
break
}
}
}
for (i in bw) {
if (load <= i * interval) {
if (COLORS) {
printf("%s\n", color[i])
} else {
printf("%s\n", bw[i])
}
break
}
}
}
'