From bf6a91943d2c5852025ed1d1aadb30d83edf0354 Mon Sep 17 00:00:00 2001 From: Ryan Schanzenbacher Date: Wed, 17 May 2023 00:21:45 -0400 Subject: Added personal channel, starting to add more dotfiles --- home-config/waybar/modules/storage.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 home-config/waybar/modules/storage.sh (limited to 'home-config/waybar/modules/storage.sh') 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 @@ +#!/bin/sh + +mount="/" +warning=20 +critical=10 + +df -h -P -l "$mount" | awk -v warning=$warning -v critical=$critical ' +/\/.*/ { + text=$4 + tooltip="Filesystem: "$1"\rSize: "$2"\rUsed: "$3"\rAvail: "$4"\rUse%: "$5"\rMounted on: "$6 + 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",\"tooltip\":\""tooltip"\", \"class\":\""class"\"}" +} +' + -- cgit v1.2.3