How do I programmatically set an application bundle on Mac OS X to run when the user logs in?
Basically, the equivalent of the HKCU\Software\Microsoft\Windows\CurrentVersion\Run
registry key in Windows.
You can add the application to the user's "Login Items" (under System Preferences=>Accounts=[user]) or you can add a launchd agent to the user's ~/Library/LaunchAgents
folder (see man launchd.plist
). Use ~/Library/LaunchDaemons/
if your app has no user-facing UI. As others point out, launchd gives you a lot of control over when the app starts, what happens if the app quits or crashes, etc. and is most appropriate for "daemon" style apps (with our without UI).
The first option (Login Items) can be manipulated programmatically (link from Gordon).