From 2ba311f62b95b4c329ba74bbcfd0e0eafa64582f Mon Sep 17 00:00:00 2001 From: Tom van der Lee Date: Mon, 10 Nov 2014 23:01:40 +0100 Subject: Network status now also ethernet --- herbstluftwm/.config/herbstluftwm/panel.sh | 32 +++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) (limited to 'herbstluftwm') diff --git a/herbstluftwm/.config/herbstluftwm/panel.sh b/herbstluftwm/.config/herbstluftwm/panel.sh index 8a2b0a4..55f2046 100755 --- a/herbstluftwm/.config/herbstluftwm/panel.sh +++ b/herbstluftwm/.config/herbstluftwm/panel.sh @@ -91,22 +91,36 @@ fi fi # Network - iwconfig=$(iwconfig wlp3s0) - if [ -z $iwconfig ] ; then - echo -e "net\toff" - else + read lo int1 int2 <<< `ip link | sed -n 's/^[0-9]: \(.*\):.*$/\1/p'` + if iwconfig $int1 >/dev/null 2>&1; then + wifi=$int1 + eth=$int2 + else + wifi=$int2 + eth=$int1 + fi + + ip link show $eth | grep 'state UP' >/dev/null && int=$eth || int=$wifi + + if [ $int == "wlp3s0" ] ; then + iwconfig=$(iwconfig $int) ssid=$(\ echo $iwconfig | \ sed "s/.*ESSID:\(\".*\"\).*/\1/" | \ sed "s/.*\(off\/any\).*/\"\1\"/" | \ sed "s/.*\"\(.*\)\".*/\1/"\ ) - if [ $ssid = "off/any" ] ; then - ifconf=$ - echo -e "net\t%{F$normal_txt}Net: No connection%{F-}" - else - echo -e "net\t%{F$normal_txt}Net: $ssid%{F-}" + + if [ $ssid != "off/any" ] ; then + echo -e "net\tNet: $ssid" + else + echo -e "net\toff" fi + + elif [ $int == "enp2s0" ] ; then + echo -e "net\tNet: ethernet" + else + echo -e "net\toff" fi # Battery -- cgit v1.2.3