diff options
Diffstat (limited to '.config/wmii-hg/rbar_wifi')
-rwxr-xr-x | .config/wmii-hg/rbar_wifi | 68 |
1 files changed, 62 insertions, 6 deletions
diff --git a/.config/wmii-hg/rbar_wifi b/.config/wmii-hg/rbar_wifi index 18395a3..195df7c 100755 --- a/.config/wmii-hg/rbar_wifi +++ b/.config/wmii-hg/rbar_wifi @@ -1,9 +1,65 @@ #!/bin/bash -. include.sh -priority=$1 +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=/' +} -while connected_to_x_server; do - echo 'label Wlan0:' $(iwconfig wlan0 | sed 's/ /\n/g' | grep Quality) >> "$WMII_DIR/rbar/${priority}_wifi" - sleep 1 -done +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; 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 + + 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" |