dotfiles/.local/bin/vpn-toggle

16 lines
538 B
Bash
Executable File

#!/usr/bin/env zsh
# 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
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
pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY TZ=Etc/UTC gpclient connect gp.usu.edu
fi