From 0850532083a9683e5d7af78c3b7a195ca9f86c36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Fri, 26 Aug 2022 10:55:12 +0200 Subject: [PATCH] feat: add network-vpn plugin (only macOS) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- INSTALL.md | 6 +++--- scripts/dracula.sh | 5 +++++ scripts/network_vpn.sh | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 3 deletions(-) create mode 100755 scripts/network_vpn.sh diff --git a/INSTALL.md b/INSTALL.md index e1b6587..0cc70b1 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -48,7 +48,7 @@ To enable plugins set up the `@dracula-plugins` option in you `.tmux.conf` file, The order that you define the plugins will be the order on the status bar left to right. ```bash -# available plugins: battery, cpu-usage, git, gpu-usage, ram-usage, network, network-bandwidth, network-ping, weather, time +# available plugins: battery, cpu-usage, git, gpu-usage, ram-usage, network, network-bandwidth, network-ping, network-vpn, weather, time set -g @dracula-plugins "cpu-usage gpu-usage ram-usage" ``` @@ -190,13 +190,13 @@ set -g @dracula-git-disable-status true Set symbol to use for when branch is up to date with HEAD ```bash -# default is ✓. Avoid using non unicode characters that bash uses like $, * and ! +# default is ✓. Avoid using non unicode characters that bash uses like $, * and ! set -g @dracula-git-show-current-symbol ✓ ``` Set symbol to use for when branch diverges from HEAD ```bash -# default is unicode !. Avoid bash special characters +# default is unicode !. Avoid bash special characters set -g @dracula-git-show-diff-symbol ! ``` diff --git a/scripts/dracula.sh b/scripts/dracula.sh index 2b5e1f4..8887f90 100755 --- a/scripts/dracula.sh +++ b/scripts/dracula.sh @@ -168,6 +168,11 @@ main() script="#($current_dir/network_ping.sh)" fi + if [ $plugin = "network-vpn" ]; then + IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-network-vpn-colors" "cyan dark_gray") + script="#($current_dir/network_vpn.sh)" + fi + if [ $plugin = "weather" ]; then # wait unit $datafile exists just to avoid errors # this should almost never need to wait unless something unexpected occurs diff --git a/scripts/network_vpn.sh b/scripts/network_vpn.sh new file mode 100755 index 0000000..468445e --- /dev/null +++ b/scripts/network_vpn.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash +# setting the locale, some users have issues with different locales, this forces the correct one +export LC_ALL=en_US.UTF-8 + +current_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +source $current_dir/utils.sh + +vpn_function() { + case $(uname -s) in + Linux | Darwin) + vpn=$(scutil --nc list | grep Connected) + + if [ -z $vpn ]; then + echo "" + else + echo "VPN" + fi + ;; + + CYGWIN* | MINGW32* | MSYS* | MINGW*) + # TODO - windows compatability + ;; + esac +} + +main() { + + echo $(vpn_function) +} + +# run main driver +main