Button with dynamic logo

Hey,

Currently I have an applescript running in my touchbar which tells me whether I am connect to my VPN or not. It is green when I am connected and red with a warning sign when I am not connected. It is as simple as telling the button to run a terminal command to verify this. However, pressing this 'button' does not do anything. By adding an action to this in bettertouchtool I want to be able to use the button as a toggle for my vpn. Hence, if the button is green (vpn is connected) I want to be able to press it such that it will disconnect (and become red) and vice versa. However, the current configuration does not work as the code is constantly running. I need some kind of line which tells the program 'wait for button press' or something. Can anyone help me out?

This is my current code:

set activeInterfaces to do shell script "ifconfig"
if activeInterfaces contains "netmask 0xffffffff" then
scutil --nc stop "NordVPN IKE"
else
scutil --nc start "NordVPN IKE"
end if

Anyone who can help me out?

Imprint | Privacy Policy