blob: 766bb1035d3a8e5aedf91496649a69da26f2d224 (
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
31
32
33
34
35
36
37
38
39
40
41
|
#!/bin/bash
wifi="/tmp/$$-wifi.icon"
# Set up tray icon
mkfifo $wifi
mktrayicon $wifi 2>/dev/null &
echo "h" > $wifi
run=1
trap 'run=0' INT;
while [[ $run -eq 1 ]]; do
# See network-manager:wifi:wext_qual_to_percent
# http://cgit.freedesktop.org/NetworkManager/NetworkManager/tree/src/wifi/wifi-utils-wext.c#n264
qual=`iwconfig 2>/dev/null | grep "Link Quality" | sed 's/.*Link Quality=\([0-9]*\/[0-9]*\) .*/\1/'`
if [[ -n $qual ]]; then
qual=`echo "100*$qual" | bc`
if ((qual<25)); then
echo "i network-wireless-signal-weak-symbolic" > $wifi;
echo "t Weak ($qual%)" > $wifi;
elif ((qual<50)); then
echo "i network-wireless-signal-ok-symbolic" > $wifi;
echo "t OK ($qual%)" > $wifi;
elif ((qual<75)); then
echo "i network-wireless-signal-good-symbolic" > $wifi;
echo "t Good ($qual%)" > $wifi;
else
echo "i network-wireless-signal-excellent-symbolic" > $wifi;
echo "t Excellent ($qual%)" > $wifi;
fi
echo "s" > $wifi;
else
echo "h" > $wifi;
fi
sleep 30
done
# Remove tray icon
echo "q" > $wifi
rm $wifi
|