# Toggle to Start/Quit GlobalProtect in macOS
###### tags: `mac` `GlobalProtect`
##### Original from: https://gist.github.com/acarril/dc03a66361e42614005562e979f2bf7c
## Regain control over the annoying GlobalProtect macOS install
I need to use [GlobalProtect](https://www.paloaltonetworks.com/products/globalprotect) because it's becoming the only VPN to access resources in my school. The VPN client is simple enough, but it does two annoying things:
1. Registers itself to autostart on login
2. Doesn't provide you with a simple 'quit' action
Here I'll show you how I fixed both issues in macOS 12.2 (Monterey).
<img width="332" alt="image" src="https://user-images.githubusercontent.com/9773292/158394064-88b1864e-3ce8-42cd-9ab0-032f1b84fbf4.png">
### 1. Disable autostart on login
This behavior is set by two files with filepaths `/Library/LaunchAgents/com.paloaltonetworks.gp.pangp[a|s].plist`. We need to edit both (with root privileges) in order to disable autostart.

I did it with [nvim](https://neovim.io/), but of course you can use any editor that you like. In my case, I run
```zsh
sudo nvim /Library/LaunchAgents/com.paloaltonetworks.gp.pangpa.plist
```
Locate the `RunAtLoad` key in line 11. Below that, change the value in line 12, which should be `true` in your file, to `false`. When you save it should read like the screenshot below.
<img width="730" alt="image" src="https://user-images.githubusercontent.com/9773292/158402059-1b0a2f46-99c6-4886-9e9e-eea10ec4e138.png">
Do the same in line 14 of the `com.paloaltonetworks.gp.pangps.plist` file, like shown below. Make sure to save all these changes, and you should be set!
<img width="730" alt="image" src="https://user-images.githubusercontent.com/9773292/158401460-6663f008-35fc-4f83-8503-b05a1d4817af.png">
### 2. Create a script to quit (and start) the client
I created a simple bash script to launch/start and stop/unload the service(s) which spawn the VPN client. The contents of the script are
```bash
#!/bin/bash
# check args
if [ $# -ne 1 ]; then
echo "provide a single argument; must be either 'load' or 'unload'"
exit 22
elif ! [[ "$1" =~ ^(load|unload)$ ]]; then
echo "argument must be either 'load' or 'unload'"
exit 22
fi
# toggle program
launchctl $1 /Library/LaunchAgents/com.paloaltonetworks.gp.pangp*
```
I named this file `globalprotect` and saved it in `~/bin/globalprotect`, where I usally store my custom scripts. To execute it, make sure to make it, well, executable:
```zsh
chmod u+x ~/bin/globalprotect
```
If you want to be able to run this from any directory in your machine, make sure to add `~/bin` to your path. In modern macOS versions this is normally done in your `~/.zshrc` file with a line like
```zsh
export PATH=${PATH}:$HOME/bin
```