feat: add network-vpn plugin (only macOS)

Signed-off-by: Tomás Migone <tomasmigone@gmail.com>
This commit is contained in:
Tomás Migone 2022-08-26 10:55:12 +02:00
parent 150daf31e1
commit 0850532083
3 changed files with 40 additions and 3 deletions

View file

@ -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 !
```

View file

@ -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

32
scripts/network_vpn.sh Executable file
View file

@ -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