summaryrefslogtreecommitdiff
path: root/.config/wmii-hg/rbar_wifi
blob: 63dc6531c0e41d6db0d45b43b882c165ab136fc9 (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
#!/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 | sed 's,$,$,' | column -s '$' -t)

	cur=''
	for item in "${list[@]}"; do
		if [[ "$item" = '* '* ]]; then
			cur="$item"
		fi
	done

	item=$(wmii9menu -i "$cur" "${list[@]}")
	if [[ -n $item ]] && [[ "$item" != '* '* ]]; then
		netctl-auto switch-to "$item"
	fi
}

. "$(dirname "$0")/rbar.sh"