USB device attach and detach events both happening at detach

So I've set up USB trigger events for when I attach my iPhone and another for when I detach my iPhone from my Mac.

It's partially firing for their respective events, but the Notifications part of it seems to be queuing up and only firing on the detach event..

So, let me clarify: the shell scripts are executing appropriately, but the Notifications are both displayed only on the detach event. I'm confused. Am I doing something wrong? I've restarted my iPhone, restarted my Mac, I even manually recreated the macro in a new macro. Any ideas on what else to try?
Thanks

Here are my macros:
**
Connect event
**

**
**
**
Disconnect event
**

I don’t know what’s going on, but the things I would try would include:

Watch the Engine.log file to see what macros are triggered when (tail -f ~/Library/Logs/‘Keyboard Maestro’/Engine.log in the Terminal may be useful, or you can open the Engine.log file in the Console app). You might like to add Log actions in various places to see what exactly Keyboard Maestro is executing when.

Start Debugging (Status Menu ➤ Start Debugging) and see if the macros are actually finishing or if the macro is stuck part way through. You may find that the Execute Script action is waiting for all its children to die before finishing, in which case even though you backgrounded the caffinate command, its still waiting on it to complete. You can resolve this by piping away all the output of the command with this loveliness:

(caffinate -dis 2>&1 >/dev/null) 2>&1 >/dev/null &
1 Like

What the what? That fixed it! Thank you! And now I’m going to go read up on shell redirection. I don’t understand the secondary redirect.

Its related to the way processes spawn children and then have to wait for them to finish in order for them not to become zombies.