I always wanted to create a script that made my lights go on and off in my home office automatically together with locking and unlocking my macbook. Now that I found the shortcuts integration that became possible. There's just one problem. How does my macbook know it's in the office and not outside or downstairs on the couch, making my family think that there's a ghost in our home that randomly switches the lights?
First I created the two items that run the action 'Kantoor aan' and 'Kantoor uit'. Those will turn off and on the lights upon locking and unlocking the screen.
Then I created a variable that is set when I connect to my home wifi. With this I could create a condition 'RichardIsHome' so that it won't trigger the automation when I'm outside of home
Did you notice the 'Did Unlock Screen' action has this condition set?
Now I only need a 'trigger' (is that the correct name) that will let me tell BTT that I'm sitting in my office. The only think I can think about is a button in my notch bar that I can switch to set a variable. But I'm not good at this.
In the end I want to add the condition 'WorkStarted == "1"' to the set of conditions in the first screenshot. Tried making a button that changes colors. Orange means the variable 'WorkStarted' is 1, grey means 0. When the button is pressed AND I'm connected to my home wifi, the lights listen to me locking and unlocking my macbook.
Here is the not working script that just loops the variable every second to 0 and 1. So I'm doing something wrong in the script. Been searching for help with these apple scripts and variables, but I'm missing some basic development/scripting skills. Can someone help me out?
tell application "BetterTouchTool" set WorkStarted to get_number_variable "WorkStarted" if WorkStarted is 0 then set_number_variable "WorkStarted" to 1 return "WorkStarted" else set_number_variable "WorkStarted" to 0 return "WorkStopped" end if return WorkStarted end tell