However if you were to run the corresponding launchctl commands in Terminal, you can alleviate the need for the reboot. Do note that /etc/nf does not exist by default, so we will need to create it.Ī reboot is necessary to load the contents of /etc/nf. However environment variables set in /etc/nf cannot have spaces and cannot reference other environment variables launchctl when run in Terminal does not suffer these limitations. The /etc/nf file contains a list of commands to be run by launchctl during startup. Try instead with HowTo: Set an Environment Variable in Mac OS X - ist Googling launchd read job label or launchd self dict (or similar) don't come up with anything useful.Note: /etc/nf is not supported in Mac OS X 10.10 and higher however launchctl is still there and will work as described here. Function SMCopyAllJobDictionaries allows me to iterate through all of the jobs, but it's not obvious how I'd find the one which invoked a particular instance of the application. With that, it appears that I can get access to the job's dictionary – ie, this information is available in principle – but I need to know the job's label first. I can see the function SMJobCopyDictionary. The obvious ways to do this are using different flags in the ProgramArguments array in the job, or to set different values in EnvironmentVariables, but both of those feel fragile, both imply duplication of bits of configuration, and both require extra documentation (“copy the value of the Label into EnvironmentVariables field FOO. If all I can do is detect the (presumed distinct) Label of the job, that will be enough (though more would be better). In particular, supposing a program foo could be started up from both A.plist and B.plist, I'd like the program to be able to preserve different state depending on which job/plist invoked it. plist, so it can adjust its behaviour based on what it finds there. I'd like the application to be able to examine the job, or the job's. plist files which invoke the application with different program arguments or in different conditions. I'm writing an application which will potentially be invoked by more than one launchd job – that is, there might be two distinct LaunchAgent.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |