BarTender 5 Trigger for VPN Status

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:

  1. Set the Viscosity (or your VPN app) to be hidden all the time
  2. Create a new trigger
  3. Set it to show Viscosity (or your VPN app) based on a “script condition”
  4. Add this to the script contents, replacing x.x.x.x on the first line 1with the IP address of your VPN connection:
  5. Save and close

For reference, here’s a screenshot showing the trigger:

BarTender 5 script trigger to show Viscosity VPN menubar icon when VPN is active
Don’t forget to replace x.x.x.x with your VPN’s actual IP address

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:

Alfred Workflows

I’ve been using Alfred on macOS for years now and it’s a wonderful productivity enhancement (on average, I use it more than 100 times a day).

Here are some of my favorite workflows:

Alfred SSH

Alfred SSH by Dean Jackson gives you quick access to SSH connections you have defined in your config, as well as quick one-off connections.

Colors

Colors by Tyler Eich is a quick way to preview color codes and convert between formats.

Datetime Format Converter

Datetime Format Converter by Michael Waterfall is the fastest way I’ve found to convert Unix timestamps to human-readable dates, and vice versa.

Dev Doctor

Dev Doctor by Syd Lawrence provides quick-reference lookups for code documentation.

DevDocs

DevDocs by Yannick Galatol is another workflow that provides quick reference for documentation using devdocs.io.

HTTP Status

HTTP Status by Marc Görtz is my preferred reference for quickly finding an HTTP status code either by number or name.

Laravel Docs

Laravel Docs by Till Krüss is amazing…it seems to have indexed most of Laravel documentation, so searching by any key word tends to bring up the best page of the documentation.

Laravel Livewire Docs

Livewire Docs searches the Laravel Livewire documentation.

Open in VS Code

I use Visual Studio Code as my primary development tool; I created this workflow to quickly and easily open a file or directory in VS Code.

TailwindCSS Docs

TailwindCSS Docs searches the TailwindCSS documentation.

VPN Manager

VPN Manager by Dean Jackson is a great way to enable/disable VPN connections on the fly.

WordPress Developer

WordPress Developer by keesiemeijer is the fastest way to search and find functions, filters, classes, and more in the WordPress documentation.