improve and fix issues shellcheck
This commit is contained in:
parent
1c9a6121ab
commit
557015eaa0
@ -1,6 +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>
|
||||||
|
|
||||||
# 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
|
||||||
@ -18,9 +19,9 @@
|
|||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
|
|
||||||
# Use the provided interface, otherwise the device used for the default route.
|
# Use the provided interface, otherwise the device used for the default route.
|
||||||
if [[ -n $BLOCK_INSTANCE ]]; then
|
if [[ -z $IF ]] && [[ -n $BLOCK_INSTANCE ]]; then
|
||||||
IF=$BLOCK_INSTANCE
|
IF=$BLOCK_INSTANCE
|
||||||
else
|
elif [[ -z $IF ]]; then
|
||||||
IF=$(ip route | awk '/^default/ { print $5 ; exit }')
|
IF=$(ip route | awk '/^default/ { print $5 ; exit }')
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -32,7 +33,7 @@ fi
|
|||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
|
|
||||||
if [[ "$(cat /sys/class/net/$IF/operstate)" = 'down' ]]; then
|
if [[ "$(cat "/sys/class/net/$IF/operstate")" = 'down' ]]; then
|
||||||
echo down # full text
|
echo down # full text
|
||||||
echo down # short text
|
echo down # short text
|
||||||
echo \#FF0000 # color
|
echo \#FF0000 # color
|
||||||
@ -49,7 +50,7 @@ case $1 in
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
# if no interface is found, use the first device with a global scope
|
# if no interface is found, use the first device with a global scope
|
||||||
IPADDR=$(ip addr show $IF | perl -n -e "/$AF ([^\/]+).* scope global/ && print \$1 and exit")
|
IPADDR=$(ip addr show "$IF" | perl -n -e "/$AF ([^\/]+).* scope global/ && print \$1 and exit")
|
||||||
|
|
||||||
case $BLOCK_BUTTON in
|
case $BLOCK_BUTTON in
|
||||||
3) echo -n "$IPADDR" | xclip -q -se c ;;
|
3) echo -n "$IPADDR" | xclip -q -se c ;;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user