Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I copied the current full .plist file at the bottom of this question.

Right now I have a .plist file that I loaded with launchctl -w load ~/Library/LaunchAgents/local.setgetscreenres.plist to make my OS X run at 2880x1800 (retina) resolution on start-up and this works fine.

However, I don't really know how to control the order of .plist files in ~/Library/LaunchAgents and sometimes it will take up to a minute before the setgetscreenres command runs after logging in. Therefore I would like to run this command before I log in, like how iStat does.

I understand that I need to move the .plist. file to /Library/LaunchAgents, chown root:wheel, and run sudo launchctl -w load, but that didn't work. Now I'm thinking there is something wrong/missing in my .plist XML.

Is there something I need to add extra in order to run as root or launch from /Library/LaunchAgents?

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN http://www.apple.com/DTDs/PropertyList-1.0.dtd >
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>local.setgetscreenres</string>
    <key>ProgramArguments</key>
    <array>
        <string>/Users/hobbes3/Code/setgetscreenres</string>
        <string>2880</string>
        <string>1800</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>KeepAlive</key>
    <false/>
    <key>AbandonProcessGroup</key>
    <true/>
</dict>
</plist>
share|improve this question
add comment

2 Answers 2

up vote 1 down vote accepted

You don't even need launchctl load -w. If you save this plist as /Library/LaunchAgents/test.plist and it's owned by root, it should be loaded automatically on login:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN http://www.apple.com/DTDs/PropertyList-1.0.dtd >
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>test</string>
    <key>ProgramArguments</key>
    <array>
        <string>say</string>
        <string>a</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
</dict>
</plist>

When I tried saving another plist like that in the user library, the say commands overlapped though.

If LimitLoadToSessionType is set to LoginWindow, the program is run when the graphical login window is shown:

<key>LimitLoadToSessionType</key>
<string>LoginWindow</string>

It is not run at all if automatic login is enabled though.

share|improve this answer
    
That worked but I ended up not running the .plist as root because as soon as I log in, Mac resize the resolution to the "Scaled: Most space" setting on the user. Is there an option to make the user .plist load before all other .plist? –  hobbes3 Apr 28 '13 at 5:50
    
I think I got it with <key>Nice</key><integer>-20</integer>. –  hobbes3 Apr 28 '13 at 5:56
add comment

Everything that is stored in ~ (your home folders) starts up or loads as soon as you log into your user. So if u want to start something at boot, you might want to have a look at the root library, so /Library/LauchAgents for your launchagents for example.

share|improve this answer
    
I put that .plist in /Library/LaunchAgents and the command didn't run on bootup. –  hobbes3 Apr 27 '13 at 6:41
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.