Working from home on a MacMini, I use work-provided VPN to connect to certain applications at the office. Otherwise, I don’t need/use that VPN. But I always forget to disconnect it.
I’d like to automate, applescript, or kludge together a visual reminder.
When I connect to workVPN, set my desktop background to solid red. When I disconnect from workVPN, restore the default wallpaper.
Glad you brought this up, as it’s something I’ve been meaning to do.
I have a keyboard maestro action that enables or disables my VPN. I just added a Set Desktop Image action for the connect and disconnect sections.
It’s kind of weird, but the way to set the desktop color is to set the desktop image to a transparent .png file, with the Fit to screen option. That will allow you to set a background color, which then fills the screen. ref
This is all specific to my client (Cisco AnyConnect), but it might get you started if you want to go this route.
Yup. I’m using Encrypt.me for my VPN which lets me check its status via AppleScript.
Other VPN apps which use standard VPN tools in macOS should be identifiable using something like this:
scutil --nc list | fgrep -q '(Connected)'
if [ "$EXIT" = "0" ]
then
echo "VPN Connected"
else
echo "VPN Disconnected"
fi
However, I know that VPNUnlimited used to work with scutil but does not any more, so other VPNs might not either. If that’s the case you’d have to ask them if they have a scriptable way to check if the VPN is active or not.
Of course you could check to see if a specific VPN app is running or not, but that doesn’t really tell you if the VPN connection is active so I do not recommend that.
n.b. I believe that feature was added (or at least clarified) after Katie Floyd asked about it when I was on Mac Power Users #321 and talked about TextBar back in 2016.
(Aside: May 2016 feels like approximately 20 years ago.)