diff options
Diffstat (limited to 'i3blocks/i3internet.sh')
-rwxr-xr-x | i3blocks/i3internet.sh | 31 |
1 files changed, 19 insertions, 12 deletions
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="⚙️ <span color='#fabd2f'>$(nmcli | grep "$wifiDev: " | cut -d' ' -f5-) $step</span>" +elif [ "$(nmcli | fgrep "$wifiDev: connecting ")" ]; then + step="$(nmcli | fgrep "$wifiDev: connecting " | sed 's/^.*(/(/;s/).*$/)/')" + wifi="$tick <span color='#fabd2f'>$(nmcli | fgrep "$wifiDev: " | cut -d' ' -f5-) $step</span>" 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="✔️ <span color='#79ff79'>$(nmcli | grep "$wifiDev: connected to " | cut -d' ' -f4-) ($(grep "^\s*w" /proc/net/wireless | awk '{print int($3 * 100 / 70)"%"}'))</span>" + wifi="$tick <span color='#79ff79'>$(nmcli | fgrep "$wifiDev: connected to " | cut -d' ' -f4-) ($(egrep '^\s*w' /proc/net/wireless | awk '{print int($3 * 100 / 70)"%"}'))</span>" 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 |