Disconnect on screen lock, and reconnect on unlock?

Got a problem with Viscosity or need help? Ask here!


Posts: 1
Joined: Wed Aug 15, 2018 10:42 am

Post by jandubois » Wed Aug 15, 2018 10:49 am
Is there a way to disconnect VPN connections when the screen is locked, and reconnect when it is unlocked again?

I realize that is the opposite of what many people want (stay connected while locking the screen), but I have a VPN server that allows only a single connection (per user), so when I forget to disconnect on my work machine, I cannot connect to the server from my laptop or my home machine.

I know I can use Screen Sharing to do a remote login to the work machine to disconnect the VPN, but I would prefer if this was all automatic (the machine is always locked when I leave, and auto-locks after a time anyways).


User avatar
Posts: 2108
Joined: Thu Sep 04, 2008 9:27 pm

Post by James » Wed Aug 15, 2018 6:08 pm
Hi jandubois,

I'm afraid Viscosity doesn't have any options for screen locked/unlocked events, however the "Disconnect connections after x minutes of inactivity" option under Preferences->Advanced would probably do the trick for disconnecting. You can set the time to match the time you have for your screen to lock or turn off when idle.

Otherwise, you should be able to find a third-party tool (e.g. ControlPlane) that allows you to invoke AppleScripts on certain actions (like the screen locking or unlocking) and then use Viscosity's scripting support to connect/disconnect your VPN connection:
https://www.sparklabs.com/support/kb/ar ... cript-mac/

James Bekkema
Viscosity Developer

Web: http://www.sparklabs.com
Support: http://www.sparklabs.com/support
Twitter: http://twitter.com/sparklabs
2 posts Page 1 of 1