38 lines
792 B
Plaintext
Raw Normal View History

#!/bin/bash
count=0
ID="$(ip link | awk '/state UP/ {print $2}')"
SSID="$(iwgetid -r)"
truncate_ssid() {
local ssid="$1"
if [[ ${#ssid} -gt 8 ]]; then
echo "${ssid:0:7}.."
else
echo "$ssid"
fi
}
net_stat () {
if (ping -c 1 archlinux.org || ping -c 1 google.com) &>/dev/null; then
if [[ $ID == e* ]]; then
echo "Online"
echo "images/icons/system/wifi.png"
else
truncated_ssid=$(truncate_ssid "$SSID")
echo "$truncated_ssid"
echo "images/icons/system/wifi.png"
fi
else
echo "Offline"
echo "images/icons/system/no-wifi.png"
fi
}
if [[ $1 == '--stat' ]]; then
net_stat | head -n1
elif [[ $1 == '--icon' ]]; then
net_stat | tail -n1
fi