From ec71cdf84cf4c2d38f42fef698e84ae1f2803e71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Sat, 11 Mar 2017 20:15:39 +0100 Subject: Ping default gateway if no internet connection detected --- config/i3blocks/scripts/iface | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'config/i3blocks') diff --git a/config/i3blocks/scripts/iface b/config/i3blocks/scripts/iface index 134d66b..a9a558b 100755 --- a/config/i3blocks/scripts/iface +++ b/config/i3blocks/scripts/iface @@ -65,11 +65,18 @@ PINGV="-c 1 -w 1" if ping $PINGV nic.cz >/dev/null 2>&1; then echo \#00FF00 # color else + # Ping nic.cz by ip if ping $PINGV 217.31.205.50 >/dev/null 2>&1; then # No DNS echo \#FFFF00 # color else - # No internet connection - echo \#FF0000 # color + # Ping default gateway of this interface + if ping $PINGV $(ip route show dev $IF | awk '/^default via/ {print $3}') >/dev/null 2>&1; then + # No internet connection but gateway accessible + echo \#FF0F00 # color + else + # No internet connection + echo \#FF0000 # color + fi fi fi -- cgit v1.2.3