summaryrefslogblamecommitdiff
path: root/i3blocks-net.sh
blob: 26aad7b21ba933c00914eda1384c439fab2ec75f (plain) (tree)
1
2
3
4
5
6
7
8
9
         

                  

                  
                                                        
                                                
                                       
                                          
                                                                               
                                                                          
                                                                       
    
                                           
  

           
#!/bin/sh
icon_ethernet=󰈁
icon_down=󰈂
icon_wireless=󰖩

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

printf "\n"