View Full Version : Execute something when an app quits?
Is there any hook mechanism (launchd, Folder Actions, watchdog, whateverintheworld) that will let me execute a Unix command after a certain application quits? Or, perhaps, when it launches, but before it has done any I/O?
I realize I could do it with InputManagers, but that's hack-ish.
Couldn't you possibly write a script of some sort (AppleScript, .sh, compiled program, whatever) that would run a command before executing the program? Or after? I don't know how you would bundle it nicely, but I'm sure you could figure that out.
Couldn't you possibly write a script of some sort (AppleScript, .sh, compiled program, whatever) that would run a command before executing the program? Or after? I don't know how you would bundle it nicely, but I'm sure you could figure that out.
But how would you have it triggered?
Simply sequentially. If you do a bash shell script, just don't background either process. Once one finishes, the other will execute.
But, like I said, it'll be ugly -- you'd have to get some kind of nice wrapper to go around it so you wouldn't constantly have a terminal shell open or an extra application icon running in your dock.
Matlab has a starter application that simply runs a shell script. It's a fairly nice wrapper that you could use for other stuff, too, I'd imagine. One difficulty would be getting the icon to hide, though.
Not an option, I'm afraid. I want people to execute the main app as usual without modification, but benefit from the change to it.
Maybe I can do something with launchd watch paths.
Yeah, a watch path actually solves this particular problem just fine. :)
I'd still like to see a solution to having something hooked in right before an app launches, or right after it quits. Maybe in launchd 2.0.
vBulletin® v3.6.4, Copyright ©2000-2024, Jelsoft Enterprises Ltd.