waybar: Add pia vpn to wireguard script

Added checking for pia connections to script in addition to existing
wireguard implementation.
This commit is contained in:
Marty Oehme 2021-12-04 11:20:29 +01:00
parent bfc19636ad
commit 55604d5538
Signed by: Marty
GPG key ID: B7538B8F50A1C800
2 changed files with 16 additions and 8 deletions

View file

View file

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