[[ "$BLOCK_BUTTON" == 2 ]] && firefox # get interface if [[ -n "$BLOCK_INSTANCE" ]]; then IF="${BLOCK_INSTANCE#long}" else IF=$(ip route | awk '/^default/ { print $5 ; exit }') fi if [[ -z "$IF" || ! -d "/sys/class/net/$IF" ]]; then printf "$IF not found\nn/a\n" exit 33 fi LAN=$(ip addr | grep -E "$IF") # check if interface is up if [[ $LAN =~ [[:space:]]UP[[:space:]] ]]; 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 LONG_TEXT="WAN $WAN_IP" SHORT_TEXT="WAN" else # LAN_IP6=$(echo $LAN | grep -oE "(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))" LONG_TEXT="LAN #TODO" SHORT_TEXT="LAN" fi #TODO: message fi #TODO: message else LONG_TEXT="$IF off" SHORT_TEXT="off" fi LOAD=false