The "Any Application" "Quits" trigger works on /System apps but not on /Application apps

Why does the following macro trigger only on apps that are stored in the /System folder and not on apps that are stored in the /Applications folder? I was hoping for it to trigger on "all apps" quitting, not just apps that are stored in a specific folder. I've also learned that about half of the apps stored in the /Applications folder are actually not really there, but are in the /System folder, which is probably some sort of alias feature of macOS, and this knowledge may come in handy for anyone trying to solve this issue.

Yes, of course, I placed this macro in its own group called Apps which is "available in all applications." So that's not the issue. I tested the following macro on about 10 apps, and if the app was located in /System it worked, but if the app was stored in /Applications it didn't work. So I conclude that it is the folder that determines if this trigger works.

I have just tried your macro and it works for applications in either location (/System/Applications/ for Apple apps; Applications for third-party apps).

Are there any clues in KM's log?

Some Apple apps are stored in the /System folder, but not all! For example, the Home app is not stored there. It is not the case that /Applications is reserved for third party apps.

When I close the Home app, the macro is not triggered, and the Engine.log file has no record of the macro being triggered.

Which apps did you test so I can try to confirm your results?

On my system, Home.app appears to be in /System/Applications. That's under MacOS 13.6.7 (Ventura). I write "appears to be" because maybe things are not as they appear... but that is what the Terminal (actually iTerm) shows me.

Keyboard Maestro Editor for one.

Doesn't work for everything here, either—Home doesn't provide notification when quit, but if you change the macro to Deactivates, you will get an announcement when you switch away from Home.

This actually isn't true any more: Apple doesn't technically install any bundled apps in /Applications, even though you'll see Safari there; they're installed in /System/Applications, and then macOS uses some magic to make them appear in the top-level Applications folder. (Keynote, Numbers, and Pages are different; they're actually in /Applications, maybe because they're not considered actual bundled apps?)

Safari is different, though—it's stored on a cryptex:

From Ventura onwards it comes wrapped in a Cryptex, a secure disk image that’s loaded during the boot process, and that locates its copy of Safari in the /Applications folder.

But that's all an aside—it doesn't seem to matter where the apps actually reside for this macro: It works for almost every app I tested, regardless of whether that app is in /Applications (third-party) or /System/Applications (Apple-provided).

@Airy, are there any apps other than Home where this macro fails for you? I didn't test every single app, but out of 20 or so (Apple and third-party), only Home failed to work.

I have a theory on why Home fails: It quits incredibly slowly. If you open Activity Monitor and search for Home, then leave that up as you quit the Home app, you'll see that the main app continues to be visible in Activity Monitor long after the GUI has vanished.

Perhaps there's some sort of timeout on the "application did quit" trigger that @peternlewis might be able to explain in more detail? But that's about the only thing I can come up with to explain why it fails to trigger that macro.

-rob.

1 Like

Ok, it's possible I was wrong about the cause being the folder location. But the symptoms persist. Starting with the Home app, which griffman confirms. Also Weather, Stocks, Podcasts, News... need I go on?

And that's it, I see the connection: Those are all Catalyst apps, apps that were ported from iOS to macOS using Apple's framework.

It seems that Catalyst apps don't include whatever notification methods native apps contain that let Keyboard Maestro know they've quit. I would guess this is some sort of Accessibility API-related entry that just isn't there for Catalyst apps, and that's what Keyboard Maestro's trigger is watching for to find apps that quit.

But Peter would have to chime in with more details, as I have no idea how that trigger is actually implemented.

-rob.

3 Likes

Wow. You're always amazing. I think I have some non-Apple apps that also fail to trigger. So it's not limited to Apple apps.

I can't mark your diagnosis as the solution since it's just a correct diagnosis. Perhaps there is no solution.

I was doing this to help another person with a problem in another thread, and I got stuck here because so many of the apps I was testing were not triggering correctly upon termination.

I imagine they are also Catalyst apps: That technology is for any developer to port their iOS apps to macOS. I just tested by installing a random iPad app from the App Store, and sure enough, no notification when it quit.

-rob.

1 Like

I had 8 windows open, but spread among 5 "Spaces". (I had not used Spaces until today.)

Wrong thread, I think :).

I've noted this down to have a look at. Keyboard Maestro lists for a system notification about the apps quitting, and I'd guess you are right that Catalyst apps just don't cause that notification to be sent when they quit.

4 Likes