From baacfff7c40e503546b40872ab7febc0ec199969 Mon Sep 17 00:00:00 2001 From: Ezri Brimhall Date: Thu, 13 Mar 2025 09:37:39 -0600 Subject: [PATCH] Updated vpn toggle --- .local/bin/vpn-toggle | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.local/bin/vpn-toggle b/.local/bin/vpn-toggle index 65ae582..d1b9001 100755 --- a/.local/bin/vpn-toggle +++ b/.local/bin/vpn-toggle @@ -1,18 +1,16 @@ #!/usr/bin/env zsh exec >(systemd-cat -t gpclient -p info) 2>&1 - # Toggles the GlobalProtect VPN connection on and off # Get the current state of the VPN connection if pgrep gpclient &>/dev/null; then # VPN is connected, so disconnect echo "Disconnecting from VPN..." - pkexec env TZ=Etc/UTC gpclient disconnect + systemctl stop usu-gpclient else # VPN is disconnected, so connect echo "Connecting to VPN..." - # pkexec doesn't pass the DISPLAY and XAUTHORITY environment variables, so we need to pass them manually - TZ=Etc/UTC sudo /usr/sbin/gpclient --fix-openssl connect gp.usu.edu + systemd-run --unit=usu-gpclient --setenv=SUDO_USER=$(whoami) --setenv=SUDO_UID=$(id -u) --setenv=SUDO_GID=$(id -g) --setenv=SUDO_HOME=$HOME --setenv=DISPLAY=$DISPLAY --setenv=XAUTHORITY=$XAUTHORITY -- /usr/sbin/gpclient --fix-openssl connect gp.usu.edu + sudo nft add element inet router vpn_cgroups \{ '"system.slice/usu-gpclient.service"' \} fi