diff --git a/bitbar-openconnect.6s.sh b/bitbar-openconnect.6s.sh index fe2a197..3e8ad22 100755 --- a/bitbar-openconnect.6s.sh +++ b/bitbar-openconnect.6s.sh @@ -13,6 +13,11 @@ # jessejoe # Displays status of a VPN interface with option to connect/disconnect. # http://i.imgur.com/RkmptwO.png +# true +# true +# true +# true +# false VPN_CONNECTED="" @@ -34,6 +39,7 @@ function notify(){ # Get location to this script from symlink SCRIPT_LOCATION=$(dirname $([ -L $0 ] && readlink -f $0 || echo $0)) +SCRIPT_NAME="$(basename "$(test -L "$0" && readlink "$0" || echo "$0")")" LOG_FILE=/tmp/vpn.log case "$1" in @@ -59,6 +65,12 @@ case "$1" in until [ -z "$(eval "$VPN_CONNECTED")" ]; do sleep 1; done notify "Disconnected" ;; + + logs) + tail -n 200 -f $LOG_FILE + exit + ;; + esac if [ -n "$(eval "$VPN_CONNECTED")" ]; then @@ -73,5 +85,11 @@ fi echo '---' echo "Edit routes | iconName=folder-symbolic href='file://$SCRIPT_LOCATION/routes.txt' refresh=false" -echo "Tail VPN log file | bash='tail -f $LOG_FILE -n 200' terminal=true refresh=false" + +LOG_CMD="$SCRIPT_LOCATION/$SCRIPT_NAME" +if [[ "$OSTYPE" == "linux-gnu"* ]]; then + LOG_CMD="$LOG_CMD logs" +fi +echo "Tail VPN log file | bash='$LOG_CMD' params='logs' terminal=true refresh=false" + exit