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.

Sorry for forgetting about this. I had to reinstall the OS and the commands work for me now.

UPDATE:
I have walked away from PIA since posting this.

I am looking into an ALGO - Cloud solution that will be cheaper and I know the players.