From ba480949ccd5f00f9cfdcae15b67ffb895965833 Mon Sep 17 00:00:00 2001 From: johannst Date: Sun, 25 Feb 2018 21:27:13 +0100 Subject: moved to i3-gaps and i3blocks --- scripts/wifi.sh | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 scripts/wifi.sh (limited to 'scripts/wifi.sh') 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" + -- cgit v1.2.3