Merge pull request #167 from tmigone/tmigone/add-network-vpn

feat: add network-vpn plugin (only macOS)
This commit is contained in:
Ethan Edwards 2023-04-08 15:14:43 -04:00 committed by GitHub
commit 51d24078c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 44 additions and 4 deletions

View file

@ -48,7 +48,8 @@ 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, attached-clients, weather, time
# available plugins: battery, cpu-usage, git, gpu-usage, ram-usage, network, network-bandwidth, network-ping, attached-clients, network-vpn, weather, time
set -g @dracula-plugins "cpu-usage gpu-usage ram-usage"
```
@ -210,13 +211,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

@ -139,7 +139,6 @@ main()
IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-git-colors" "green dark_gray")
tmux set-option -g status-right-length 250
script="#($current_dir/git.sh)"
elif [ $plugin = "battery" ]; then
IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-battery-colors" "pink dark_gray")
@ -170,6 +169,10 @@ main()
IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-network-ping-colors" "cyan dark_gray")
script="#($current_dir/network_ping.sh)"
elif [ $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)"
elif [ $plugin = "attached-clients" ]; then
IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-attached-clients-colors" "cyan dark_gray")
script="#($current_dir/attached_clients.sh)"

36
scripts/network_vpn.sh Executable file
View file

@ -0,0 +1,36 @@
#!/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)
# TODO
;;
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