From 6f08e747e264286d841a20932822f0533ed07576 Mon Sep 17 00:00:00 2001 From: luchianmihai Date: Fri, 7 Feb 2020 02:12:12 +0200 Subject: [PATCH] added dwm_wpa.sh --- bar-functions/dwm_wpa.sh | 80 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100755 bar-functions/dwm_wpa.sh diff --git a/bar-functions/dwm_wpa.sh b/bar-functions/dwm_wpa.sh new file mode 100755 index 0000000..e02e118 --- /dev/null +++ b/bar-functions/dwm_wpa.sh @@ -0,0 +1,80 @@ +#!/bin/mksh + +dwm_wpa() { + CONSTATE=$(wpa_cli status | sed -n '/wpa_state/s/^.*=//p') + + case $CONSTATE in + 'COMPLETED') + CONSSID=$(wpa_cli status | sed -n '/\/s/^.*=//p') + CONIP=$(wpa_cli status | sed -n '/ip_address/s/^.*=//p') + CONRSSI=$(wpa_cli signal_poll | sed -n '/AVG_RSSI/s/^.*=//p') + if [ "$CONRSSI" -gt -35 ]; then + printf "%s" "$SEP1" + printf "\uF927 %s %s" "$CONSSID" "$CONIP" + printf "%s\n" "$SEP2" + elif [ "$CONRSSI" -ge -55 ] && [ "$CONRSSI" -lt -35 ]; then + printf "%s" "$SEP1" + printf "\uF924 %s %s" "$CONSSID" "$CONIP" + printf "%s\n" "$SEP2" + elif [ "$CONRSSI" -ge -75 ] && [ "$CONRSSI" -lt -55 ]; then + printf "%s" "$SEP1" + printf "\uF921 %s %s" "$CONSSID" "$CONIP" + printf "%s\n" "$SEP2" + else + printf "%s" "$SEP1" + printf "\uF91E %s %s" "$CONSSID" "$CONIP" + printf "%s\n" "$SEP2" + fi + ;; +#======================================================================# + 'DISCONNECTED') + printf "%s" "$SEP1" + printf "\uF92D %s" "$CONSTATE" + printf "%s\n" "$SEP2" + ;; + 'INTERFACE_DISABLED') + printf "%s" "$SEP1" + printf "\uF92D %s" "$CONSTATE" + printf "%s\n" "$SEP2" + ;; +#======================================================================# + 'SCANNING') + printf "%s" "$SEP1" + printf "\uF92A %s" "$CONSTATE" + printf "%s\n" "$SEP2" + ;; + 'ASSOCIATING') + printf "%s" "$SEP1" + printf "\uF92A %s" "$CONSTATE" + printf "%s\n" "$SEP2" + ;; + 'ASSOCIATED') + printf "%s" "$SEP1" + printf "\uF92A %s" "$CONSTATE" + printf "%s\n" "$SEP2" + ;; + 'AUTHENTICATING') + printf "%s" "$SEP1" + printf "\uF92A %s" "$CONSTATE" + printf "%s\n" "$SEP2" + ;; +#======================================================================# + '4WAY_HANDSHAKE') + printf "%s" "$SEP1" + printf "\uF92B %s" "$CONSTATE" + printf "%s\n" "$SEP2" + ;; + 'GROUP_HANDSHAKE') + printf "%s" "$SEP1" + printf "\uF92B %s" "$CONSTATE" + printf "%s\n" "$SEP2" + ;; + 'INACTIVE') + printf "%s" "$SEP1" + printf "\uF92B %s" "$CONSTATE" + printf "%s\n" "$SEP2" + ;; + esac +} + +dwm_wpa