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:

VS Code and Laravel Tasks

Several of my recent projects are Laravel apps that use Horizon to manage the queue and run jobs.

However, I frequently forgot to run php artisan horizon when opening the project, and sometimes spent a bit of time trying to figure out why a job hadn’t run before remembering. 🤦

In addition—and this is a relatively minor annoyance—even when I do remember to start Horizon, sometimes I’d like to see the metrics dashboard showing how many jobs have run in the past few minutes.

Edit: I added npm run dev to help with Tailwind JIT mode and Vite asset building.

Workspace Tasks

Enter VS Code’s Tasks feature. This can automatically start running tasks when a workspace is opened.

To get set up:

  1. If you haven’t yet, go to File > Save Workspace As… and save a workspace config file to somewhere on your hard drive
  2. Open the command palette (command-shift-P) and activate “Tasks: Manage Automatic Tasks in Folder”
  3. Activate “Allow Automatic Tasks”
  4. Open the command palette again and activate “Workspaces: Open Workspace Configuration File”
  5. Add the following to the workspace config file:

Now every time I open the workspace, assets are rebuilt as I modify them and Horizon and the scheduler start running automatically.