diff options
author | johannst <stoelp@eit.uni-kl.de> | 2018-02-25 21:27:13 +0100 |
---|---|---|
committer | johannst <stoelp@eit.uni-kl.de> | 2018-02-25 21:27:13 +0100 |
commit | ba480949ccd5f00f9cfdcae15b67ffb895965833 (patch) | |
tree | df70100706b3b2726e3b04074ed0430378af3008 /scripts/wifi.sh | |
parent | 32cff6de87dbc18a10c73f5514ae61181c120756 (diff) | |
download | dotfiles-ba480949ccd5f00f9cfdcae15b67ffb895965833.tar.gz dotfiles-ba480949ccd5f00f9cfdcae15b67ffb895965833.zip |
moved to i3-gaps and i3blocks
Diffstat (limited to 'scripts/wifi.sh')
-rwxr-xr-x | scripts/wifi.sh | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/scripts/wifi.sh b/scripts/wifi.sh new file mode 100755 index 0000000..6f8417a --- /dev/null +++ b/scripts/wifi.sh @@ -0,0 +1,42 @@ +#!/bin/bash +# dotfiles -- scripts/wifi.sh +# author: johannst + +if="${BLOCK_INSTANCE:-wlp3s0}" +[[ ! -d /sys/class/net/${if} ]] && exit 0 + +show_ap_mac=0 +show_ap_quality=0 +show_ap_name=0 +for arg in "$@"; do + case $arg in + -aq | --ap_quality) show_ap_quality=1 + ;; + -am | --ap_mac) show_ap_mac=1 + ;; + -an | --ap_name) show_ap_name=1 + ;; + *) # ignore unknown + ;; + esac +done + +AP_NAME=$(iwgetid -r $if) +AP_MAC=$(iwgetid -a $if | sed 's/.*\(\([0-9A-F]\{2\}:\)\{5\}[0-9A-F]\{2\}\).*/\1/') +AP_QUALITY=$(grep $if /proc/net/wireless | awk '{ print int($3 * 100 / 70) }')% + +# first ipv4 addr +IP_ADDR=$(ip address show $if | grep 'inet ' | sed 's/\s\+inet \([0-9.]\+\)\/.*/\1/') + +OUT="$IP_ADDR" +if [[ $show_ap_name == 1 && $show_ap_quality == 1 ]]; then + OUT="$OUT ($AP_NAME $AP_QUALITY)" +elif [[ $show_ap_name == 1 ]]; then + OUT="$OUT ($AP_NAME)" +elif [[ $show_ap_quality == 1 ]]; then + OUT="$OUT ($AP_QUALITY)" +fi +[[ $show_ap_mac == 1 ]] && OUT="$OUT $AP_MAC" + +echo "$OUT" + |