-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatus_script.sh
56 lines (52 loc) · 1.09 KB
/
status_script.sh
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/sh
# shell script to prepend i3status with more stuff
if [[ ! -p "/tmp/i3statusP" ]]; then
mkfifo "/tmp/i3statusP"
fi
i3status --config ~/.config/i3/i3status > /tmp/i3statusP &
cpref="[{\"name\":\"keyboard layout\",\"markup\":\"none\",\"full_text\":\""
getlo(){
lo=$(xkblayout-state print %s/%v)
lol=${#lo}-1
if [ ${lo:$lol} = "/" ]; then
lo=${lo:0:$lol}
fi
# soviet boost:
if [ "$lo" == "ru" ]; then
lo="CCCP"
fi
# boosted!
}
setrm(){
tf="$(sed -n 's/^.*ram: \([.0-9]*\).*$/\1/p' <<<$postf)"
rl=$((7-${#tf}))
ijs=" "
ijs="${ijs:0:rl}"
postf="$(sed "s/ram:/${ijs}ram:/" <<<$postf)"
}
(while :; do
read line
if [ "$line" = "" ]; then
break
elif [ "$line" = U ]; then
getlo
echo $pref$cpref$lo"\"},""$postf"
else
poc=${line:0:2}
if [ "$poc" = "[{" ]; then
pref=""
postf="${line:1}"
getlo
setrm
echo $pref$cpref$lo"\"},""$postf"
elif [ "$poc" = ",[" ]; then
pref=","
postf="${line:2}"
getlo
setrm
echo $pref$cpref$lo"\"},""$postf"
else
echo $line
fi
fi
done) < /tmp/i3statusP