BarTender is a wonderful little macOS app that you can use to hide menubar apps that you don’t need to see very often.
I also use the Viscosity VPN client and have Bartender set to hide the Viscosity icon, but I would love it to be visible if the VPN is active.
This should also work for any other VPN client that uses menu bar item, not just Viscosity.
Thanks to a new BarTender feature named “Triggers,” this is possible:
- Set the Viscosity (or your VPN app) to be hidden all the time
- Create a new trigger
- Set it to show Viscosity (or your VPN app) based on a “script condition”
- Add this to the script contents, replacing
x.x.x.x
on the first line 1with the IP address of your VPN connection: - Save and close
For reference, here’s a screenshot showing the trigger:
Viscosity With Multiple VPNs
If you use Viscosity and have multiple possible VPN connections, this script may work better for you:
It uses AppleScript to check the status of all Viscosity connections and should cause the menu icon to display if any of them are active, rather than looking for a specific IP address.
Bonus: AppleScript App to Toggle a Specific Viscosity Connection
Bonus: update line one with the name of your Viscosity connection, and save this script with the “Application” file format. Then you can use it in Raycast, Alfred, Spotlight, etc. to toggle one specific connection on and off:
Thanks! I’ve been trying to get this to work with expressvpn using ‘compare image’ function with no result. so googled scripting and came across your post. 🙂 Do you know if there’s a script to get Bartender’s active preset? I want to see what preset Bartender’s using in a little window on my screen for a time. I’ll use Better touch tool or whatever I find to display a floating window. That would be super helpful!
cheers.
I don’t. In Script Editor you can use the `File > Open Dictionary…` command to open Bartender and see what commands are available: https://support.apple.com/guide/script-editor/view-an-apps-scripting-dictionary-scpedt1126/mac