From 58a9e65b5554b2c9552540dfea96b562375cf321 Mon Sep 17 00:00:00 2001 From: InigoGutierrez Date: Mon, 2 Dec 2019 14:23:33 +0100 Subject: Mon 02 Dec 2019 02:23:33 PM CET --- i3blocks/i3internet.sh | 31 +++++++++++++++++++------------ i3blocks/i3music.sh | 7 ++++--- 2 files changed, 23 insertions(+), 15 deletions(-) (limited to 'i3blocks') diff --git a/i3blocks/i3internet.sh b/i3blocks/i3internet.sh index 2f55fd2..4065a31 100755 --- a/i3blocks/i3internet.sh +++ b/i3blocks/i3internet.sh @@ -8,30 +8,37 @@ case $BLOCK_BUTTON in esac wifiDev="wlp2s0" -ethDev="enp3s0" -wstatus=$(cat /sys/class/net/$wifiDev/operstate) -estatus=$(cat /sys/class/net/$ethDev/operstate) +ethDev="" +wstatus="$(cat /sys/class/net/$wifiDev/operstate)" +estatus="$(cat /sys/class/net/$ethDev/operstate)" +tick=✅ +wifiSymbol="📶" +ethSymbol="🌐" if [ "$wstatus" = "down" ]; then wifi="❌" -elif [ "$(nmcli | grep "$wifiDev: connecting ")" ]; then - step="$(nmcli | grep "$wifiDev: connecting " | sed 's/^.*(/(/;s/).*$/)/')" - wifi="⚙️ $(nmcli | grep "$wifiDev: " | cut -d' ' -f5-) $step" +elif [ "$(nmcli | fgrep "$wifiDev: connecting ")" ]; then + step="$(nmcli | fgrep "$wifiDev: connecting " | sed 's/^.*(/(/;s/).*$/)/')" + wifi="$tick $(nmcli | fgrep "$wifiDev: " | cut -d' ' -f5-) $step" else # with IP - #wifi="✔️$(nmcli | grep "$wifiDev: connected to " | cut -d' ' -f4-) ($(ip addr show $wifiDev | grep "inet " | cut -d' ' -f6)) ($(grep "^\s*w" /proc/net/wireless | awk '{print int($3 * 100 / 70)"%"}'))" + #wifi="$tick$(nmcli | fgrep "$wifiDev: connected to " | cut -d' ' -f4-) ($(ip addr show $wifiDev | fgrep "inet " | cut -d' ' -f6)) ($(egrep "^\s*w" /proc/net/wireless | awk '{print int($3 * 100 / 70)"%"}'))" # with name - wifi="✔️ $(nmcli | grep "$wifiDev: connected to " | cut -d' ' -f4-) ($(grep "^\s*w" /proc/net/wireless | awk '{print int($3 * 100 / 70)"%"}'))" + wifi="$tick $(nmcli | fgrep "$wifiDev: connected to " | cut -d' ' -f4-) ($(egrep '^\s*w' /proc/net/wireless | awk '{print int($3 * 100 / 70)"%"}'))" fi -if [ -z "$(nmcli | grep $ethDev)" ]; then + +[ -z "$ethDev" ] && echo "$wifiSymbol$wifi" && exit 0 + +if [ -z "$(nmcli | fgrep "$ethDev")" ]; then en="❌❗ No $ethDev" elif [ "$estatus" = "down" ]; then en="❌" else # with IP - #en=$(ip addr show $ethDev | grep "inet " | cut -d' ' -f6) + #en=$(ip addr show $ethDev | fgrep "inet " | cut -d' ' -f6) # no IP - en=✔️ + en=$tick fi -echo "📶$wifi 🌐$en" +echo "$wifiSymbol$wifi $ethSymbol$en" +exit 0 diff --git a/i3blocks/i3music.sh b/i3blocks/i3music.sh index cad0b66..d446b50 100755 --- a/i3blocks/i3music.sh +++ b/i3blocks/i3music.sh @@ -7,18 +7,19 @@ case $BLOCK_BUTTON in esac symbol=🎵 -ampersand="I" +ampersand='and' # & in echo messes up script pgrep -x cmus >/dev/null || exit 0 stat="$(cmus-remote -Q | grep "^status " | awk '{print $2}' | sed "s/&/$ampersand/")" artist="$(cmus-remote -Q | grep "^tag artist " | cut -d' ' -f3- | sed "s/&/$ampersand/")" title="$(cmus-remote -Q | grep "^tag title " | cut -d' ' -f3- | sed "s/&/$ampersand/")" [ -z "$artist" ] && artist="(unknown)" -[ -z "$title" ] && title="$(basename "$(cmus-remote -Q | grep "^file" | cut -d' ' -f2- | sed "s/&/$ampersand/")")" # sed to fix & in title messing up script +[ -z "$title" ] && title="$(basename "$(cmus-remote -Q | grep "^file" | cut -d' ' -f2- | sed "s/&/$ampersand/")")" if [ "$stat" = "playing" ]; then - #echo "$symbol $artist ─ $title" echo "$symbol $artist ─ $title" + echo "$symbol ...$title" elif [ "$stat" = "paused" ]; then echo "$symbol ( $artist ─ $title )" + echo "$symbol ( ...$title )" else echo "$symbol $stat" fi -- cgit v1.2.1