diff --git a/README.md b/README.md
index 185e152..5d93209 100644
--- a/README.md
+++ b/README.md
@@ -13,6 +13,8 @@ git clone this repo
brew install openconnect
brew install vpn-slice
brew install oath-toolkit
+brew install swiftbar
+brew install terminal-notifier
```
Add server address, username, password and 2fa seed in keychain with these names:
diff --git a/bitbar-openconnect.sh b/bitbar-openconnect.sh
new file mode 100755
index 0000000..a4756e9
--- /dev/null
+++ b/bitbar-openconnect.sh
@@ -0,0 +1,65 @@
+#!/bin/bash
+
+# Get current status of a VPN connection with options to connect/disconnect.
+# Working with OpenConnect, but can work with any executable VPN. Commands
+# that require admin permissions should be whitelisted with 'visudo', e.g.:
+#
+#joesmith ALL=(ALL) NOPASSWD: /path/to/always-on-openconnect-vpn/run-vpn.sh
+#joesmith ALL=(ALL) NOPASSWD: /usr/bin/killall -2 openconnect
+
+# VPN Status
+# v1.0
+# Jesse Jarzynka
+# jessejoe
+# Displays status of a VPN interface with option to connect/disconnect.
+# http://i.imgur.com/RkmptwO.png
+
+VPN_CONNECTED="ifconfig | grep -E -A1 tun | grep inet"
+
+function notify(){
+ if [[ "$OSTYPE" == "darwin"* ]]; then
+ terminal-notifier -title "VPN" -message "${1}" -sender "SwiftBar"
+ fi
+ if [[ "$OSTYPE" == "linux-gnu"* ]]; then
+ notify-send "VPN" "${1}"
+ fi
+}
+
+# Get location to this script from symlink
+SCRIPT_LOCATION=$(dirname $([ -L $0 ] && readlink -f $0 || echo $0))
+LOG_FILE=/tmp/vpn.log
+
+case "$1" in
+ connect)
+ notify "Connecting..."
+
+ # For Linux desktop use DBUS to use keychain
+ export DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS
+
+ cd $SCRIPT_LOCATION
+ sudo --preserve-env $SCRIPT_LOCATION/run-vpn.sh &>> $LOG_FILE &
+
+ until eval "$VPN_CONNECTED"; do sleep 1; done
+ notify "Connected!"
+ ;;
+ disconnect)
+ eval "sudo killall -2 openconnect"
+ until [ -z "$(eval "$VPN_CONNECTED")" ]; do sleep 1; done
+ notify "Disconnected"
+ ;;
+esac
+
+if [ -n "$(eval "$VPN_CONNECTED")" ]; then
+ echo "VPN ✔"
+ echo '---'
+ echo "Disconnect VPN | bash='$0' param1=disconnect terminal=false refresh=true"
+else
+ echo "VPN ✘"
+ echo '---'
+ echo "Connect VPN | bash='$0' param1=connect terminal=false refresh=true"
+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"
+exit