blob: 1244464ad97b2a7989c51aa25dc41ea3a7a860c2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
#!/bin/sh
# This script requires dnsutils aka bind to fetch the WAN IP address
# Shows the connections names
# nmcli connection show --active | grep 'ethernet' | awk '{ print $1 }' FS=' '
# nmcli connection show --active | grep 'wifi' | awk '{ print $1 }' FS=' '
# Show ethernet interface name
# nmcli connection show --active | grep 'ethernet' | awk '{ print $6 }' FS=' '
# Show wifi interface name
# nmcli connection show --active | grep 'wifi' | awk '{ print $4 }' FS=' '
ShowInfo() {
# if [ "$(nmcli connection show --active | grep -oh "\w*ethernet\w*")" == "ethernet" ]; then
# wan="$(dig @resolver4.opendns.com myip.opendns.com +short)"
# connection="$(nmcli connection show --active | grep 'ethernet' | awk '{ print $6 }' FS=' '): $(nmcli connection show --active | grep 'ethernet' | awk '{ printf "%s\nLAN IP:",$1 }' FS=' ') $(nmcli -t -f IP4.ADDRESS dev show $(nmcli connection show --active | grep 'ethernet' | awk '{ print $6 }' FS=' ') | awk '{printf "%s\nWAN IP: '$wan'", $2}' FS='[:/]')"
# elif [ "$(nmcli connection show --active | grep -oh "\w*wifi\w*")" == "wifi" ]; then
# wan="$(dig @resolver4.opendns.com myip.opendns.com +short)"
# connection="$(nmcli connection show --active | grep 'wifi' | awk '{ print $4 }' FS=' '): $(nmcli connection show --active | grep 'wifi' | awk '{ printf "%s\nLAN IP:",$1 }' FS=' ') $(nmcli -t -f IP4.ADDRESS dev show $(nmcli connection show --active | grep 'wifi' | awk '{ print $4 }' FS=' ') | awk '{printf "%s/nWAN IP: '$wan'", $2}' FS='[:/]')"
# else
# connection="No active connection."
# fi
fyi -i "network-idle" --hint string:x-canonical-private-synchronous:network-status "$connection"
}
IconUpdate() {
# if [ "$(nmcli connection show --active | grep -oh "\w*ethernet\w*")" == "ethernet" ]; then
icon=""
# elif [ "$(nmcli connection show --active | grep -oh "\w*wifi\w*")" == "wifi" ]; then
# icon=""
# else
# icon=""
# fi
printf "%s" "$icon"
}
if [ "$1" = "ShowInfo" ]; then
ShowInfo
else
IconUpdate
fi
|