#!/bin/bash # start firefox [[ "$BLOCK_BUTTON" == 3 ]] && firefox # get LONG status if [[ "$BLOCK_BUTTON" == 1 ]]; then [[ "$LONG" = true ]] && LONG=false || LONG=true fi [[ "$BLOCK_INSTANCE" =~ "long" ]] && LONG=true # get interface if [[ -n "$BLOCK_INSTANCE" ]]; then IF="${BLOCK_INSTANCE#long}" else IF=$(ip route | awk '/^default/ { print $5 ; exit }') fi # check if network interface is empty if [[ -z "$IF" ]]; then [[ "$LONG" = true ]] && echo "No interface" || echo "n/a" exit 33 fi # check if the network interface exists if [[ ! -d "/sys/class/net/$IF" ]]; then [[ "$LONG" = true ]] && echo "No interface" || echo "n/a" exit 33 fi # get interface information LAN=$(ip addr | grep -E "$IF") # check if interface is up if [[ "$LAN" =~ " UP " ]]; then # check if interface is connected if [[ "$LAN" =~ \<.*UP.*\> ]]; then WAN_IP=$(curl -s checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/<.*$//') # check if internet connection is established if [[ "$?" -eq 0 && $WAN_IP != "" ]]; then if [[ "$LONG" = true ]]; then echo $WAN_IP echo $WAN_IP echo "#04B431" else echo wan echo wan echo "#04B431" fi else echo "lan" fi fi else [[ "$LONG" = true ]] && echo "$IF: off" || echo "off" fi