4 if [[ "$(uname)" == "Linux" ]]; then
5 wifi_interface
=$
(ip route |
awk '/^default.*wlp/ {print $5}')
6 eth_interface
=$
(ip route |
awk '/^default.*enp/ {print $5}')
8 if [ $wifi_interface ];then
9 wifi_ssid
=$
(iw dev
$wifi_interface link |
grep SSID | cut
-d " " -f 2-)
10 wifi_strength
=$
(grep "^\s*w" /proc
/net
/wireless |\
11 awk '{print int($3 * 100 / 70) "%"}')
12 wifi_ip
=$
(hostname
-i |
awk '{ print $1 }')
13 wifi_result
="Wifi\t($wifi_interface)\n$wifi_ssid\t$wifi_strength\
17 if [ $eth_interface ];then
18 eth_ip
=$
(ifconfig
$eth_interface |
awk '/inet / {print $2}')
19 eth_result
="Ethernet\t($eth_interface)\n$eth_ip"
22 elif [[ "$(uname)" == "OpenBSD" ]]; then
23 wifi_interface
=$
(netstat
-rn |
grep default |
awk '{print $8}')
26 if [ $wifi_interface ];then
27 wifi_ssid
=$
(ifconfig
$wifi_interface |
grep join |
awk '{print $3}')
28 wifi_strength
=$
(ifconfig
$wifi_interface |
grep join |\
29 awk '{print int((-0.0154*$8*$8)-(0.3794*$8)+98.182) "%"}')
30 wifi_ip
=$
(ifconfig
$wifi_interface |
grep inet |
awk '{print $2}')
31 wifi_result
="Wifi\t($wifi_interface)\n$wifi_ssid\t$wifi_strength\
34 # if [ $eth_interface ];then
40 # public_ip=$(curl https://ipecho.net/plain)
42 notify-send
"Network details" "$wifi_result$eth_result"