How to get VPN Toggle button?

Hi, I'm relatively new to BTT but I'm * this * close to having the perfect touchbar! The only thing I need is a button to quickly toggle my System Preferences VPN on/off. I've seen some solutions to this problem, but none I've been able to follow and they all seem needlessly complicated for what I'm after. Does anybody have a solution for me?

(touch button - VPN on / touch again - VPN off)

Thanks :blush:

This is the bugger for me here. Idk how to help you there, there is a way though using the VPN Utility Tunnelblick which has full apple script support. I'll be glad to help you out through this utility of no-one comes up with a solution supporting the system VPN :frowning:


Use this command to connect the VPN configured with the name “myVPN”:
$ networksetup -connectpppoeservice "myVPN"

The following command will disconnect again:
$ networksetup -disconnectpppoeservice "myVPN"

If you want to check the connection status, use:
$ networksetup -showpppoestatus "myVPN"

You would have to work with Shell Script Widgets. The widget itself will have to run the check the connection command, and depending on the output you can configure one or another icon in BTT (it's quite simple to setup).
I don't know though how to create if commands in Shell, because the associated action, the one to perform if you hit the button, would be:

  1. Check the connection
  2. Depending on the result, run the connect to VPN or disconnect from VPN command line.

More information here.

Maybe someone else can help out here :wink:

Wow, thank you so much, that's so amazingly generous of you! I really appreciate your help! I'm still really in the dark about using scripts, but I love jumping into new skills and tinkering around so thank you so much again for pointing me in the right direction :relaxed:.