aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'dot_config/i3/scripts/executable_disk')
-rw-r--r--dot_config/i3/scripts/executable_disk48
1 files changed, 48 insertions, 0 deletions
diff --git a/dot_config/i3/scripts/executable_disk b/dot_config/i3/scripts/executable_disk
new file mode 100644
index 0000000..e18c7aa
--- /dev/null
+++ b/dot_config/i3/scripts/executable_disk
@@ -0,0 +1,48 @@
1#!/usr/bin/env bash
2# Copyright (C) 2014 Julien Bonjean <[email protected]>
3
4# This program is free software: you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation, either version 3 of the License, or
7# (at your option) any later version.
8
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13
14# You should have received a copy of the GNU General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17DIR="${DIR:-$BLOCK_INSTANCE}"
18DIR="${DIR:-$HOME}"
19ALERT_LOW="${ALERT_LOW:-$1}"
20ALERT_LOW="${ALERT_LOW:-10}" # color will turn red under this value (default: 10%)
21
22LOCAL_FLAG="-l"
23if [ "$1" = "-n" ] || [ "$2" = "-n" ]; then
24 LOCAL_FLAG=""
25fi
26
27df -h -P $LOCAL_FLAG "$DIR" | awk -v label="$LABEL" -v alert_low=$ALERT_LOW '
28/\/.*/ {
29 # full text
30 print label $4
31
32 # short text
33 print label $4
34
35 use=$5
36
37 # no need to continue parsing
38 exit 0
39}
40
41END {
42 gsub(/%$/,"",use)
43 if (100 - use < alert_low) {
44 # color
45 print "#FF0000"
46 }
47}
48'
Powered by cgit v1.2.3 (git 2.41.0)