Terminal run on startup command

Discussion in 'Mac Applications and Mac App Store' started by Zogw, Jan 24, 2013.

  1. macrumors newbie

    Joined:
    Jan 24, 2013
    #1
    Is there a command that anyone knows of that will make an application open on startup? I know how to do it manually, but can it be done from Terminal? Thanks.
     
  2. macrumors 68030

    CylonGlitch

    Joined:
    Jul 7, 2009
    Location:
    SoCal
    #2
    Not 100% sure what you want. You can go to the Preferences Panel, Users & Groups, Login Items and add things there. Is that what you want?
     
  3. thread starter macrumors newbie

    Joined:
    Jan 24, 2013
    #3
    Sorry, I guess I was a little unclear. I'm wondering if there's an actual command that one can type in terminal that will make an application open at startup. For example, the command that hides files is
    Code:
    chflags hidden ~/yourfile/
    so, something like that.
     
  4. LPZ, Jan 24, 2013
    Last edited: Jan 26, 2013

    LPZ
    macrumors 65816

    Joined:
    Jul 11, 2006
    #4
    The open command can be used to open an application. With the help of launchd, it can be invoked at login. For an example, create a file named local.example.safariopener.plist and paste in the following text:

    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>local.example.safariopener</string>
        <key>ProgramArguments</key>
        <array>
            <string>/usr/bin/open</string>
            <string>-a</string>
            <string>/Applications/Safari.app</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
    </dict>
    </plist>
    
    Save the file and place it in ~/Library/LaunchAgents, where ~ denotes your home folder. The next time you log in, Safari should open automatically.
     
  5. thread starter macrumors newbie

    Joined:
    Jan 24, 2013
    #5
    Thanks, that sounds good.
     
  6. thread starter macrumors newbie

    Joined:
    Jan 24, 2013
    #6
    Oh I tried it, and it doesn't work. I think I might be confused about which Library folder to put it in as I have one for the user and one for the system. I tried it for the user (the home folder).
     
  7. LPZ
    macrumors 65816

    Joined:
    Jul 11, 2006
    #7
    Sorry, a mistake in my post. Forgot the correct suffix on the filename.

    Name the file local.example.safariopener.plist, not local.example.safariopener. It should open Safari on log in. If you place it in ~/Library/LaunchAgents (in your home folder), it will only work for you. If you place it in /Library/LaunchAgents, it should work on login for each user.

    Sorry for the error.
     
  8. thread starter macrumors newbie

    Joined:
    Jan 24, 2013
    #8
    Thanks, it worked perfectly!
     

Share This Page