Hello.
Launchctl feels a little bit awkward to work with doesn’t it? -I have a copy of Lingon around, to write all the xml tags for me. My approach is that launchctl is telling launchd to run stuff. launchd runs as process nr 0, or talks with it, so everything I am setting in launchd’s environment, is inherited from there.
Anyways, you should think of the -w flag as write it makes the changes your set to be persistent. That is what the gibberish means. (In order for launchctl to work, it reads the contents of the property list file, so the -w option writes that it is to be launched, or whatever into the property list file.
What I’ll try to do, is set an environment variable. Restart Finder and Terminal app, and then see if the environment variable is changed.
I’ll also try to figure out, if I can make it with a login item after that.
I’'ll do this during the day, when I’m bored of reading.
Edit
I opened a terminal window, and I executed first myname=McUsr
After that I executed launchctl setenv myvar $myvar
in the same terminal window.
Then I fired up AppleScript editor, and ran
do shell script "echo $myvar"
And I got what I wanted back.
When trying to run this in a new terminal window, I don’t get the correct result back of course, because the environment has alread been read in when Terminal.app started, and the environment is pretty much frozen from the outside at that point.
But this means that login items will work for me.
It beats me that I started AppleScript Editor from Spotlight the first time. Now I’ll start from Finder:
That worked too; it reflected the change of my previous launchctl command. It makes sense, since Finder uses launchservices anyway.
So, I am good by making an applescript login item applet, with the setenv command in it.
And I have time to play more with the AsObj-C global system’s menu app that are “self-editing” that I created yesterday.