blob: f83d92168a614ad0d44f8e1c9159a83f7072f27d (
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
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
|
#!/bin/bash
iwinfo() {
local interface=$1
iwconfig "$interface" |
sed -r 's/ {2,}/\n/g' |
sed -e '/^\s*$/d' -e 's/:\s*/=/' \
-e '1s/^/Interface=/' \
-e '2s/^/MAC Protocol=/'
}
update() {
local id
id=$1
setup_trap "$id"
while true; do
{
printf 'label '
iwinfo wlp2s0|grep -E '^(ESSID|Link Quality)='|sed 'N;s/\n/ | /'
} | write "$id"
sleep 1
done
}
right-click() {
local list cur item
list=()
IFS=''
while read -r line; do
list+=("$line")
done < <({ netctl-auto list | sort -k1.2; printf '> %s\n' 'New Network' 'Disable All' 'Enable All';} | sed 's,$,$,' | column -s '$' -t)
cur=''
for item in "${list[@]}"; do
if [[ "$item" = '* '* ]]; then
cur="$item"
fi
done
IFS=$' \t\n'
item=$(wmii9menu -i "$cur" "${list[@]}")
case "$item" in
'')
# Nothing selected
;;
'* '*)
# Already selected; do nothing
;;
'> New Network'*)
urxvt +sb -title wifi-menu -e sudo wifi-menu
;;
'> Disable All'*)
sudo netctl-auto disable-all
;;
'> Enable All'*)
sudo netctl-auto enable-all
;;
*)
# NB: do NOT quote $item; we need to strip whitespace
sudo netctl-auto switch-to $item
;;
esac
}
. "$(dirname "$0")/rbar.sh"
|