Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

NixxereBB

macrumors newbie
Original poster
Jun 11, 2013
4
0
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.
 

NixxereBB

macrumors newbie
Original poster
Jun 11, 2013
4
0
Thanks, I'll take a look at the link you provided..

Here is the post that brought me to your answer:


https://forums.macrumors.com/threads/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

macrumors newbie
Original poster
Jun 11, 2013
4
0
Thanks chown33!

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:


Code:
<?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>
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.