PIA VPN Automation with KM

I wanted to activate my PIA VPN without touching my trackpad.

Thankfully, they have added Command-Line control to their client app:

Here is the shell script I used as a toggle, I hope it saves someone some time:

#!/bin/bash

case $(piactl get connectionstate) in
	Disconnected)
		piactl connect
		;;
	Connected)
		piactl disconnect
		;;
	Interupted)
		piactl connect
		;;
	Disconnecting)
		echo "Disconnecting"
		;;
	DisconnectingToReconnect)
		echo "Trying to reconnect now"
		;;
	*)
		piactl connect
		;;
esac

2 Likes

For some reason I’m not able to get this to work. Keyboard Maestro doesn’t display the script results like it should though. Is this still working for you? If so, I may need to fix KM.

Do the commands work for you in the terminal?

Sorry I didn’t know anyone replied. I’ll check when I have a chance later today.