PDA

View Full Version : chown33 - launchagent-daemon help if you could assist




NixxereBB
Jun 11, 2013, 06:11 PM
Hello, I'm new to the forum, and saw a post from some time ago answered by chown33, and thought I'd see if I could get some direction from you in a new post rather than reply to an old one. Do you have an example of this type of plist I could use as a base, and is it able to run a app compiled applescript before login, or is it constrained to only be able to run certain types of scripts/programs? THANKS for any help/example plist you can offer!


Originally Posted by CodeBreaker View Post
Correct me if I am wrong. I believe Launch Agents are run on behalf of a user and hence need a user to be logged in to the OS, whereas Launch Daemons can be run even if no one is logged into the OS.

That's basically right, but see the man pages for launchd.plist and launchctl. Look at the plist key LimitLoadToSessionTypes, then at the -S option to launchctl which lists the session types. The LoginWindow session type will run a launch agent at the login window. For example, I have a wacom graphics tablet whose LaunchAgents plist file contains Aqua and LoginWindow session types. This means it runs even when no one is logged in. The file is owned by root, and is unwritable to others.

I have not experimented with the other session types.



chown33
Jun 11, 2013, 07:29 PM
What's the URL of the old thread?

http://www.mikeash.com/getting_answers.html

All I know about those plists is what I read in the docs and in the Wacom plists.

NixxereBB
Jun 11, 2013, 07:40 PM
Thanks, I'll take a look at the link you provided..

Here is the post that brought me to your answer:


http://forums.macrumors.com/showthread.php?t=1337857 (http://forums.macrumors.com/showthread.php?t=1337857)

Basically, I am trying to get an app to run without a login on system start, and found that Aqua session was required (errno 5).. I'd pretty much given up until I saw your post referencing the session control, so I've started reading the man pgs you gave to see what I can learn.

NixxereBB
Jun 11, 2013, 09:26 PM
with the reference to 'loginwindow' and 'background' the app runs both before login as well as while any user is logged in..

Thanks for the help.

This is what I used in case any others are looking for similar functionality:


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.xci.inventory</string>
<key>LimitLoadToSessionType</key>
<array>
<string>Background</string>
<string>LoginWindow</string>
</array>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/open</string>
<string>-W</string>
<string>/Applications/xci/xciInventory.app</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>StartInterval</key>
<integer>6000</integer>
<key>WorkingDirectory</key>
<string>/Applications/xci</string>
</dict>
</plist>