-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathi3statusExtra.sh
executable file
·140 lines (124 loc) · 3.43 KB
/
i3statusExtra.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#!/bin/sh
source ~/.i3/i3statusExtra.conf
notificationFile="/tmp/notification"
notificationTimeFile="/tmp/notificationTime"
notificationDuration=3
cWhite="#ffffff"
cGreen="#20c020"
cOrange="#ffe000"
cRed="#c00000"
function block {
if [ -z "$3" ]; then st="$2"; else st="$3"; fi
echo '{"color": "'"$1"'", "full_text": "'"$2"'", "short_text": "'"$st"'"},'
}
function getSoundCards {
echo "$(aplay -l | awk 'BEGIN {lastN = ""}
/card/ {n = substr($2, 0, 1);
if (n != lastN) {
lastN = n;
printf n"="$3" "
}
}')"
}
if [ "$1" == "notify" ]; then
echo "$2" > "$notificationFile"
echo "$notificationDuration" > "$notificationTimeFile"
killall -USR1 i3status
exit 1
fi
/usr/bin/i3status -c ~/.i3/i3status.conf | while :
do
read line
#shortcuts="$(~/.i3/shortcutsBar.sh)" TODO Causes SIGPIPE
# NOTIFICATIONS
notification=''
if [ -f "$notificationFile" ]; then
notification="$(cat $notificationFile 2>/dev/null)"
fi
#notificationTime="$(cat $notificationTimeFile 2>/dev/null)" # TODO Causes SIGPIPE
if [ "$notification" ]; then
notification="$(block "$cWhite" "$notification" "$notification")"
echo "$(( $notificationTime - 1 ))" > "$notificationTimeFile"
if [ "$notificationTime" -le "1" ]; then
echo '' > "$notificationFile"
echo '' > "$notificationTimeFile"
fi
fi
sound=''
if [ "$so_bar" = true ]; then
set $(sh ~/.i3/sound.sh get)
if [ "$1" == "on" ]; then sound="$(block "$cWhite" " $2")";
else sound="$(block "$cOrange" " $2")"; fi
fi
wireless=''
if [ "$wi_bar" = true ]; then
set $(sh ~/.i3/wireless.sh get)
case "$1" in
COMPLETED)
wireless="$(block "$cGreen" " ${2:0:16} $3" " ${2:0:6}")";;
SCANNING)
wireless="$(block "$cOrange" " Scanning" " -")";;
DISCONNECTED)
wireless="$(block "$cRed" " Disconnected" " -")";;
ASSOCIATING)
wireless="$(block "$cOrange" " Associating" " +")";;
ASSOCIATED)
wireless="$(block "$cOrange" " Associated" " +")";;
AUTHENTICATING)
wireless="$(block "$cOrange" " Autentificating" " +")";;
4WAY_HANDSHAKE|GROUP_HANDSHAKE)
wireless="$(block "$cOrange" " Handshake" " +")";;
INACTIVE)
wireless="$(block "$cRed" " Inactive" " x")";;
INTERFACE_DISABLED)
wireless="$(block "$cRed" " Disabled" " x")";;
OFF)
wireless="$(block "$cRed" " OFF" " x")";;
esac
fi
ethernet=''
if [ "$wi_bar" = true ]; then
set $(sh ~/.i3/ethernet.sh get)
case "$1" in
RUNNNING)
ethernet="$(block "$cGreen" " $2" " Connected")";;
CONNECTING)
ethernet="$(block "$cOrange" " $2" " +")";;
DISCONNECTED)
ethernet="$(block "$cRed" " Disconnected" " -")";;
OFF)
ethernet="$(block "$cRed" " OFF" " x")";;
esac
fi
battery=''
if [ "$ba_bar" = true ]; then
set $(sh ~/.i3/battery.sh get)
logos=" "
for i in {0..8..2}; do
if [ $(echo $2 | tr -d '%') -le $((100-$i*12)) ]; then
logo=${logos:$i:2}
else
break
fi
done
if [ "$3" == "on-line" ]; then logo=" $logo"; fi
if [ $(echo $2 | tr -d '%') -le $ba_alert ]; then color="$cRed"
elif [ $(echo $2 | tr -d '%') -le $ba_warning ]; then color="$cOrange"
else color="$cGreen"; fi
battery="$(block "$color" "$logo$2" "$logo$2")"
fi
backlight=''
if [ "$bl_bar" = true ]; then
set $(sh ~/.i3/bl-brightness.sh get)
backlight="$(block "$cWhite" "☀ $1%")"
fi
if [ "$shortcuts" ]; then
echo "${line/\[*\]/\["$shortcuts"\]}"
else
out="$notification"
for cell in $order; do
out+="${!cell}"
done
echo "${line/\[/\[$out}"
fi
done