diff options
author | Eduardo Pedroni <e.pedroni91@gmail.com> | 2015-11-01 17:33:24 +0100 |
---|---|---|
committer | Eduardo Pedroni <e.pedroni91@gmail.com> | 2015-11-01 17:33:24 +0100 |
commit | 9807eec36f001273c83a1b29027b311b145dc80d (patch) | |
tree | db8e4df8577aed4d89b518efa5ab681d0cb41628 /dwm-statusbar | |
parent | cd3f6f4dc13333624d9f4e22cca748896a9d6042 (diff) |
Added strength to wlan function
Diffstat (limited to 'dwm-statusbar')
-rwxr-xr-x | dwm-statusbar | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/dwm-statusbar b/dwm-statusbar index 27ded09..723675a 100755 --- a/dwm-statusbar +++ b/dwm-statusbar @@ -219,19 +219,44 @@ print_eth() { echo -ne "${icon_colour}\uE0E4${eth_colour}${eth_ip}" } -# Configure the adapter to display above +# Configure the adapter to display above, strength might need to be tweaked print_wlan() { + + wifi_status=$(ip addr show dev wlan0 | awk 'NR==1 {print $9}') + + if [ "$wifi_status" == "UP" ]; then + + wifi_ip=$(ip addr show dev wlan0 | awk 'NR==3 {print $2}' | sed -r 's/\/.*/, /') + + else + icon_colour=${colour_faded} + fi + + wlan_status=$(ip addr show dev ${wlan_adapter} | awk 'NR==1 {print $9}') if [ "$wlan_status" == "UP" ]; then wlan_ip=$(ip addr show dev ${wlan_adapter} | awk 'NR==3 {print $2}' | sed -r 's/\/.*//') - icon_colour=${colour_neutral} - wlan_colour=${colour_normal} + + let wlan_strength="10 * $(cat /proc/net/wireless | awk 'NR==3 {print substr($3, 1, 2)}') / 7" + if [ $wlan_strength -lt 25 ]; then + icon_colour=${colour_critical} + wlan_colour=${colour_critical} + elif [ $wlan_strength -lt 50 ]; then + icon_colour=${colour_warning} + wlan_colour=${colour_warning} + else + icon_colour=${colour_neutral} + wlan_colour=${colour_normal} + fi + + wlan_strength="${wlan_strength}%" + else icon_colour=${colour_faded} fi - echo -ne "${icon_colour}\uE401${wlan_colour}${wlan_ip}" + echo -ne "${icon_colour}\uE401${wlan_colour}${wlan_ip}${wlan_strength}" } while true; do |