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 know you can run applications on startup on a Mac, but can you run an Automator action, a Service, a shell script, or an AppleScript on startup instead?

I also know you can save all of these as an application, but I don't want it opening in the dock.

share|improve this question

2 Answers 2

up vote 6 down vote accepted

First of all, login is distinct from startup. This answer assumes you mean login, as you apparently refer to the ability to start programs as configured in System Preferences » Users & Groups.


Run Automator scripts using the command line utility automator, and AppleScripts using osascript. Their man pages explain the usage in detail.

You can set a login hook, but it is rather outdated and deprecated in favor of launchd.

You can create launchd jobs by placing XML configuration files in your ~/Library/Launch Agents directory. This site contains quite a few rather minimal examples, and you can view e.g. /System/Library/Launch Agents for examples of system-provided launchd jobs. You need the RunAtLoad directive for launchd.


You still can save your AppleScripts and Automator scripts as applications, and run them as such. To hide them from the Dock, edit their Contents/Info.plist file and add an LSUIElement directive as described e.g. here. This will hide its Dock icon and menu.

share|improve this answer
    
+1 & accepted answer –  gadgetmo Jan 2 '12 at 15:31

You could save a property list like this as ~/Library/LaunchAgents/some.label.plist.

<?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>some.label</string>
    <key>ProgramArguments</key>
    <array>
        <string>automator</string>
        <string>/path/to/example.workflow</string>
        <!-- <string>osascript</string>
        <string>/path/to/example.scpt</string> -->
    </array>
    <key>RunAtLoad</key>
    <true/>
</dict>
</plist>

It has to be loaded first by running launchctl load ~/Library/LaunchAgents/some.label.plist or logging out and back in once.

share|improve this answer

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.