From 55604d55389fe36b138098bf3d6ddc7576b343d4 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Sat, 4 Dec 2021 11:20:29 +0100 Subject: [PATCH] waybar: Add pia vpn to wireguard script Added checking for pia connections to script in addition to existing wireguard implementation. --- wayland/.config/waybar/colorscheme.css | 0 wayland/.config/waybar/modules/wireguard | 24 ++++++++++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) create mode 100644 wayland/.config/waybar/colorscheme.css diff --git a/wayland/.config/waybar/colorscheme.css b/wayland/.config/waybar/colorscheme.css new file mode 100644 index 0000000..e69de29 diff --git a/wayland/.config/waybar/modules/wireguard b/wayland/.config/waybar/modules/wireguard index fe8d717..82256b8 100755 --- a/wayland/.config/waybar/modules/wireguard +++ b/wayland/.config/waybar/modules/wireguard @@ -72,6 +72,17 @@ function get_conns { done < <($1) } +function get_pia { + if ! command -v piactl >/dev/null 2>&1; then + return 1 + fi + + status=$(piactl get connectionstate) + if [[ $status = "Connected" ]]; then + connected+=("$(piactl get region): $(piactl get vpnip)") + fi +} + function print_conns { local first="yes" local array_print="$1[@]" @@ -110,23 +121,20 @@ function array_contains { echo "no" } -if [[ $nargs == 0 ]]; then +if [[ $nargs == 0 ]] || [[ $printjson = "yes" ]]; then get_conns "$wgactive" + get_pia print_conns connected elif [[ $showmenu == "yes" ]]; then get_conns "$wgconns" + get_pia print_conns connected "list" print_conns available "list" -elif [[ $printjson == "yes" ]]; then - get_conns "$wgactive" - print_conns connected - -elif - [[ $dotoggle == "yes" ]] -then +elif [[ $dotoggle == "yes" ]]; then get_conns "$wgconns" + get_pia if [[ "$(array_contains connected "$conn")" == "yes" ]]; then $nmclicmd down "$conn"