aboutsummaryrefslogtreecommitdiff
path: root/configs/xmobar_iostat.sh
blob: 662c21f60f6ebf15abfd3d090837d562a5226d15 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/sh

OUT=$(dstat -dD total --noheaders --noupdate --integer 1 1 | tail -n 1)
# | sed -n 's/^\s*\([0-9]*[[:alpha:]]*\).*$/__\1___/p'

READ=$(echo $OUT | sed -n 's/^\s*\([0-9]*[[:alpha:]]*\).*$/\1/p')
WRITE=$(echo $OUT | sed -n 's/^\s*[0-9]*[[:alpha:]]*\s*\([0-9]*[[:alpha:]]*\)$/\1/p')


outio() {
local lc
lc=$(echo "$1" | cut -c $((${#1})))
if [ $lc = "k" ]; then
	echo -n '<fc=#FFFF00>'
elif [ $lc = "B" ]; then
	echo -n '<fc=#00FF00>'
elif [ $lc = "M" ]; then
	echo -n '<fc=#FF0000>'
else
	echo -n '<fc=#FFFFFF>'
fi
echo -n "${1}</fc>"
}

outio "${READ}"
echo -n ' | '
outio "${WRITE}"
echo

exit $?