always ip
This commit is contained in:
parent
a1ac296557
commit
6538c52080
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Copyright (C) 2014 Julien Bonjean <julien@bonjean.info>
|
# Copyright (C) 2014 Julien Bonjean <julien@bonjean.info>
|
||||||
# Copyright (C) 2014 Alexander Keller <github@nycroth.com>
|
# Copyright (C) 2014 Alexander Keller <github@nycroth.com>
|
||||||
# Copyright (C) 2019 Jesús E. <heckyel@hyperbola.info>
|
# Copyright (C) 2020 Jesús E. <heckyel@hyperbola.info>
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -33,15 +33,10 @@ IF="${IF:-$(ip route | awk '/^default/ { print $5 ; exit }')}"
|
|||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
|
|
||||||
AF=${ADDRESS_FAMILY:-inet6?}
|
|
||||||
LABEL="${LABEL:-}"
|
LABEL="${LABEL:-}"
|
||||||
|
|
||||||
for flag in "$1" "$2"; do
|
for flag in "$1" "$2"; do
|
||||||
case "$flag" in
|
case "$flag" in
|
||||||
-4)
|
|
||||||
AF=inet ;;
|
|
||||||
-6)
|
|
||||||
AF=inet6 ;;
|
|
||||||
-L)
|
-L)
|
||||||
if [[ "$IF" = "" ]]; then
|
if [[ "$IF" = "" ]]; then
|
||||||
LABEL="iface "
|
LABEL="iface "
|
||||||
@ -51,19 +46,15 @@ for flag in "$1" "$2"; do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ "$IF" = "" ]] || [[ "$(cat "/sys/class/net/$IF/operstate")" = 'down' ]]; then
|
if [[ "$IF" = "" ]] || [[ "$(cat "/sys/class/net/$IF/operstate")" = 'down' ]];
|
||||||
echo "${LABEL}down" # full text
|
then
|
||||||
echo "${LABEL}down" # short text
|
echo "${LABEL}down" # text
|
||||||
echo \#FF0000 # color
|
echo \#FF0000 # color
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# look for the vpn connection, if no interface is found, use the first device with a global scope
|
# Check local ip address
|
||||||
if [[ $(ip addr show tun0) ]]; then
|
IPADDR=$(ip route get 4.2.2.1 | awk '{print $NF;exit}')
|
||||||
IPADDR=$(ip addr show tun0 | awk '/inet.*brd/ {print $2}' | awk -F'/' '{print $1}')
|
|
||||||
else
|
|
||||||
IPADDR=$(ip addr show "$IF" | perl -n -e "/$AF ([^\/]+).* scope global/ && print \$1 and exit")
|
|
||||||
fi
|
|
||||||
|
|
||||||
case $BLOCK_BUTTON in
|
case $BLOCK_BUTTON in
|
||||||
3) echo -n "$IPADDR" | xclip -q -se c ;;
|
3) echo -n "$IPADDR" | xclip -q -se c ;;
|
||||||
@ -71,5 +62,4 @@ esac
|
|||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
|
|
||||||
echo "$LABEL$IPADDR" # full text
|
echo "$LABEL$IPADDR"
|
||||||
echo "$LABEL$IPADDR" # short text
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user