summaryrefslogtreecommitdiff
path: root/home-config/waybar/modules/storage.sh
diff options
context:
space:
mode:
Diffstat (limited to 'home-config/waybar/modules/storage.sh')
-rwxr-xr-xhome-config/waybar/modules/storage.sh25
1 files changed, 25 insertions, 0 deletions
diff --git a/home-config/waybar/modules/storage.sh b/home-config/waybar/modules/storage.sh
new file mode 100755
index 0000000..90cc3dc
--- /dev/null
+++ b/home-config/waybar/modules/storage.sh
@@ -0,0 +1,25 @@
1#!/bin/sh
2
3mount="/"
4warning=20
5critical=10
6
7df -h -P -l "$mount" | awk -v warning=$warning -v critical=$critical '
8/\/.*/ {
9 text=$4
10 tooltip="Filesystem: "$1"\rSize: "$2"\rUsed: "$3"\rAvail: "$4"\rUse%: "$5"\rMounted on: "$6
11 use=$5
12 exit 0
13}
14END {
15 class=""
16 gsub(/%$/,"",use)
17 if ((100 - use) < critical) {
18 class="critical"
19 } else if ((100 - use) < warning) {
20 class="warning"
21 }
22 print "{\"text\":\""text"\", \"percentage\":"use",\"tooltip\":\""tooltip"\", \"class\":\""class"\"}"
23}
24'
25