From 7149994889691ea3414e943a68077ca821250611 Mon Sep 17 00:00:00 2001 From: Enrico Fasoli Date: Fri, 25 Sep 2015 18:27:33 +0200 Subject: [PATCH] lemonbar now uses connman --- lemonbar.sh | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/lemonbar.sh b/lemonbar.sh index 1c9f433..3b44e7f 100755 --- a/lemonbar.sh +++ b/lemonbar.sh @@ -40,14 +40,24 @@ getMPD(){ } getNET(){ - if [ ! -f /tmp/myip ]; then - echo "$(curl -s --connect-timeout 1 http://canihazip.com/s)" > /tmp/myip - fi - IP="$(cat /tmp/myip)" - if [ -n "$IP" ]; then - echo -n "%{F$GREEN}$IP" + NDATA=$(connmanctl services | grep "*A") + NSTATE=$(echo $NDATA | cut -b3) + NNAME=$(echo $NDATA | cut -d' ' -f2) + + if [ "$NSTATE" == "c" ]; then + NCOLOR="$GREY" + elif [ "$NSTATE" == "R" ]; then + NCOLOR="$BLUE" + elif [ "$NSTATE" == "O" ]; then + NCOLOR="$GREEN" else + NCOLOR="$RED" + fi + + if [ "$NCOLOR" == "$RED" ]; then echo -n "%{F$RED}Offline" + else + echo -n "%{F$NCOLOR}$NNAME" fi }