This repository packages a small utility that keeps an eye on Private Internet Access split tunneling on macOS. The check_pia_split.sh script reads the official PIA settings file, tracks the previous state in a per user file, and fires a macOS notification if split tunneling ever drifts into the off state. The installer and uninstaller scripts wrap the entire workflow so you can drop the watcher onto a fresh machine or remove it without hunting through system folders.
- macOS with the standard PIA desktop client installed. The client provides
piactland keeps/Library/Preferences/com.privateinternetaccess.vpn/settings.jsonup to date. piactlavailable somewhere on your system. The installer searches common locations plus whatever is on yourPATH.jqfor parsing JSON. Install it withbrew install jqif you do not already have it.- A user that can run
sudocommands since installing the watcher places files into/usr/local/binand edits~/Library/LaunchAgents.
-
Clone or extract this repository anywhere under your user account.
-
From the project root run
chmod +x setup.sh uninstall.sh update.sh check_pia_split.sh test_run.shonce if needed. -
Execute the installer:
./setup.sh
The script refuses to run as root. It verifies macOS, validates that
jq,piactl,launchctl,plutil, andsudoare ready, then prompts for your sudo password to install the monitoring script into/usr/local/bin/check_pia_split.sh. -
The installer also writes a LaunchAgent plist at
~/Library/LaunchAgents/com.<user>.pia-split-tunnel-monitor.plist, pointing to the installed checker with a default interval of 60 seconds. Override the interval by exportingPIA_START_INTERVAL=<seconds>before launchingsetup.sh. -
Once the script finishes it reloads the agent automatically. Confirm it is running with
launchctl list | grep pia-split-tunnel-monitor. Logs are written to~/Library/Logs/pia-split-tunnel-monitor.logand.err.
- Reads
/Library/Preferences/com.privateinternetaccess.vpn/settings.jsonevery minute by default and extractssplitTunnelEnabledwithjq. - Stores the last known on or off state in
~/.pia_split_tunnel_stateso you only get a notification when the state flips to off instead of on every poll. - Optionally auto repairs the split tunnel setting by calling
piactl -u applysettings '{"splitTunnelEnabled":true}'whenAUTO_FIX_SPLIT_TUNNELinside the checker is set totrue. - Displays a macOS notification using
osascriptthe first time it sees the off state, along with a submarine alert sound.
If you ever want to remove the watcher while keeping PIA installed, run the uninstaller from the project root:
./uninstall.shIt unloads and deletes the LaunchAgent plist, removes /usr/local/bin/check_pia_split.sh, deletes the state file, and clears the default log files. The script prompts for sudo when removing the binary. Afterward you can run launchctl list | grep pia-split-tunnel-monitor to confirm the agent is gone.
After pulling new code from this repository, refresh the installed watcher with:
./update.shThe updater copies the latest check_pia_split.sh into /usr/local/bin, rewrites the embedded piactl path if needed, and reloads the LaunchAgent so it runs the new version without touching your existing plist or logs.
Want to see what happens before touching your real PIA install? Run the harness:
./test_run.shIt feeds check_pia_split.sh a temporary settings file, stores state under a temp directory, and echoes the notification text instead of invoking macOS Notification Center. The script walks through an initial enabled state, a disabled state, and recovery so you can watch the transitions and exit codes.
- Confirm the LaunchAgent is loaded:
launchctl list | grep pia-split-tunnel-monitor. A line with the label indicates macOS will keep the checker running after every reboot. - Inspect the logs in
~/Library/Logs/pia-split-tunnel-monitor.logand.errfor any output. Healthy runs are usually silent, so any new lines typically point to a configuration issue. - Manually run
/usr/local/bin/check_pia_split.sh(or./test_run.sh) to trigger the logic on demand. Toggle split tunneling off in the PIA app and you should see a notification the next time the checker runs.
The LaunchAgent writes stdout and stderr to ~/Library/Logs/pia-split-tunnel-monitor.log and .err. The checker automatically trims each file to 256 KiB on every run so they do not grow without bound. Tune or disable the behavior by exporting:
PIA_LOG_MAX_BYTES=<bytes>to set a custom size cap (default 262144 bytes).PIA_TRIM_LOGS=falseif you prefer to handle truncation yourself.
You can also override the log paths with PIA_STDOUT_LOG and PIA_STDERR_LOG if you edit the LaunchAgent accordingly.
- If the installer reports that the PIA settings file is missing, launch the PIA desktop app once and toggle split tunneling so the file exists.
- When notifications never appear, check the permissions on
/Library/Preferences/com.privateinternetaccess.vpn/settings.json. Your user must be able to read it without sudo. - Look at the log files in
~/Library/Logsfor any runtime errors. They usually contain the full stderr output from the checker. - If you relocate
piactl, rerun./setup.shso the installed script is updated with the new path.
Joshua Weller (https://joshdw.com)
Released under the MIT License. See LICENSE for details.