summaryrefslogtreecommitdiffstats
path: root/.local/bin/conky/getif.sh
blob: cf7d9218d4cdbf7e6e191c0a13ad9085964ccf0f (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
#!/bin/sh

# ifconfig | command grep '^[a-z]' | awk '{print $1}' | sed '{/lo/d;s/://;}'

case "$(hostname -s)" in
	mother)
		if_main="eth1"
		if_alt="eth0"
		;;
	po-rbo)
		if_main="enx4ce1734c425a"
		if_alt="wlp1s0"
		;;
	fbsd-tp)
		if_main="em0"
		if_alt="wlan0"
		exit
		;;
esac

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
	echo '${font1}NETWORK ${hr}${font}
${color #928374}No network${font}'
	exit
fi

echo -n $if_main