bar/scripts/network.sh (view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
#!/usr/bin/env bash
# Find the first wireless interface
connection_type=$(iw dev | awk '$1=="Interface"{print $2; exit}') #gets network type (wired/wifi)
network_name=$(iw dev $connection_type link | awk -F': ' '/^\s*SSID:/ {print $2}')
signal_strength=$(iw dev $connection_type link | awk '/signal:/ {print $2}')
if [ -n $signal_strength ]; then
case "$signal_strength" in
-50) bars=4;;
-60) bars=3;;
-70) bars=2;;
-80) bars=1;;
*) bars=0;;
esac
echo -n "$bars"+"$network_name"
else
echo -n "disconnected"
fi
|