I am trying to detect when specific applications are starting.
I am currently using NSWorkspace , registering for the notification “made application launch”. I also use the runningApplications method to launch applications that are currently running when the application starts.
For most applications, the application name is sufficient. I have a plist from "known applications" that I cross-check with the name given in the notification.
This works fine until you come across an application that acts as a proxy to run another application using command line arguments.
Example: A recently released portal on Mac does not have a dedicated application package. Steam can create a shortcut that serves as nothing more than launching the hl2_osx application with the -game argument and portal as a parameter.
As more source-based games are routed to the Mac, I assume they will use the same method to launch, effectively launching the hl2_osx application with the -game argument.
Is there a good way to get a list of arguments (and their parameters) using the Cocoa API?
NSProcessInfo comes close by offering the `-arguments' method, but provides information only for its own process ...
NSRunningApplication offers the ability to retrieve information about arbitrary applications using the PID, but there is no args command line ...
Is there something that fills the gap between the two?
I try not to go down the path of creating NSTask to run ps -p [pid] and parse the output ... I would prefer something higher.
source share