summaryrefslogtreecommitdiffstats
path: root/.local/bin/conky/net.sh
blob: 4baf43b775332872e889f4b1e4eb816538c5bbd4 (plain)
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
44
45
46
47
48
#!/bin/sh

case "$(hostname -s)" in
	mother)
		if_main="eth1"
		if_alt="eth0"
		;;
	po-rbo)
		if_main="enx34298f762de7"
		if_alt="wlp1s0"
		if_vpnssl="vpn0"
		;;
	mars)
		if_main="em0"
		if_alt="wlan0"
		exit
		;;
esac

if_wg="wg0"
if [ -e "/sys/class/net/$if_wg/operstate" ] && ! [ -z $(ifconfig $if_wg 2>/dev/null | awk '/inet / {print $2}') ]; then
	:
else
	if_wg=""
fi

if grep up "/sys/class/net/$if_main/operstate" >/dev/null 2>&1 && ! [ -z $(ifconfig $if_main 2>/dev/null | awk '/inet / {print $2}') ]; then
	:
elif grep up "/sys/class/net/$if_alt/operstate" >/dev/null 2>&1 && ! [ -z $(ifconfig $if_alt 2>/dev/null | awk '/inet / {print $2}') ]; then
	if_main=$if_alt
else
	:
fi

if [ -z $if_vpnssl ]; then
	:
elif ! ip a | grep $if_vpnssl | grep UP >/dev/null 2>&1; then
	if_vpnssl=""
fi

echo $if_main'${font}'
[ -z $if_wg ] || echo '${color5}${font2}WireGuard ${color0}${font}ON${font}'
[ -z $if_wg ] || echo '${color5}${font2}WG  IP   ${color0}${font}${goto 80}${addr '$if_wg'}${font}'
[ -z $if_vpnssl ] || echo '${color5}${font2}Forti VPN-SSL ${color0}${font}ON${font}'
[ -z $if_vpnssl ] || echo '${color5}${font2}VPN IP  ${color0}${font}${goto 80}${addr '$if_vpnssl'}${font}'
echo '${voffset 3}${color5}${font2}LAN IP   ${color0}${font}${goto 80}${addr '$if_main'}${font}'
echo '${color5}${font2}DNS IP  ${color0}${font}${goto 80}${nameserver 0}${if_match "${nameserver 1}" != ""}, ${nameserver 1}${endif}${font}'
echo '${color5}${font2}WAN IP ${color0}${font}${goto 80}${execi 15 curl -s https://ifconfig.me || echo No WAN}${font}'