Trigger for leaving home?

I want a trigger that fires when I leave home. I've tried using the "This wireless network - with exact name - is disconnected" trigger, but it seems to fire only when I arrive back home, not when I wake up my computer away from home. Any suggestions?

If it were me I would use the Sleep trigger. I'm not sure if that will work when you just close the lid of the laptop. You'll just have to test it.

But Sleep Trigger will fire when my laptop goes to sleep, whether it's at home or not. Am I correct?

You cannot generally detect when you are about to leave home, and by the time you leave home your Mac would presumably already be asleep and thus cannot run a macro, so the first opportunity will be when you wake the Mac somewhere else.

Therefore a trigger on wake, and detecting the wireless network state would be the way to go.

Personally, I would track whether you are at home or not in a variable (eg "DND_AtHome" (DND = Do Not Delete, just a convention people use for variables that are semi-permanent). I would have a macro that triggered on Wake, Sleep, or Any Wireless Network is connected or disconnected.

I would then have the macro check the WirelessNetwork token name and determine whether I was at home or not, and then note if the state has changed from that saved in the variable. If so, set the variable accordingly and act on the change accordingly.

Since I invented that convention, let me make it clear.

Using a prefix of "DND" means that the variable should never be deleted outside of a macro that uses the variable. Many of us have macros or scripts that "delete" all KM variables that are not needed. Using this prefix allows us to exclude these variables from the "deletion" process. It also allows you to quickly find/see these variables in the KM Editor > Preferences > Variables pane.