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: