summaryrefslogtreecommitdiff
path: root/i3blocks-net.sh
blob: b3d72392766bfc3142cb4513188d424c8aa9526f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/sh
icon_ethernet=󰈁
icon_down=󰈂
icon_wireless=󰖩

is_ethernet=$(ifconfig em0 | grep status | cut -d\: -f2)
if [ "$is_ethernet" = " active" ]; then
	inet=$(ifconfig lagg0 | grep inet\ | cut -w -f3)
	printf "%s%s\n" $icon_ethernet $inet
elif [ "$(ifconfig wlan0 | grep status | cut -d\: -f2)" = " associated" ]; then
	ssid=$(ifconfig wlan0 | grep ssid\  | cut -w -f3)
	[ -n "$ssid" ] && printf "%s%s" $icon_wireless "$ssid"
else
	printf "%sNo connection" $icon_down
fi

printf "\n"