source: dotfiles/guix/.config/i3blocks/disk@ 53e5e13

Last change on this file since 53e5e13 was 53e5e13, checked in by Mikhail Kirillov <w96k@…>, on Mar 12, 2020 at 7:22:49 PM

Add i3blocks bar for sway

  • Property mode set to 100755
File size: 1.2 KB
RevLine 
[53e5e13]1#!/bin/sh
2# Copyright (C) 2014 Julien Bonjean <julien@bonjean.info>
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 "HDD: " $3 "/" $2
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'
Note: See TracBrowser for help on using the repository browser.