views:

247

answers:

1

How can I add a start up item via command line on a mac? From googling, I know you have to edit ~/Library/Preferences/com.apple.loginitems.plist using defaults write com.apple.loginitems [key] [value] but i'm not sure exactly which things to edit.

A: 

On Mac OS X 10.6 Snow Leopard, it is even simpler than that:

sudo launchctl submit -l name_of_startup_item -- command [args]

See man launchctl. On earlier versions, it is recommended that you create a Launch Daemon PLIST file and load/start it with launchctl rather than create a startup item... the startup items are the old school way.

Michael Aaron Safyan
thanks. The thing is, the application i'm trying to add to the startup items (Growl) has its own preference pane in system preferences, where the user can check a box to add it to the list of start up items themselves. If they added Growl to the start up items through system preferences, and my script also told launchd about it, would the system end up trying to open two copies on login? Or do I not have to worry about that?
adam n
@adam, Why are you trying to start Growl? Just use the Growl framework to send notifications... it will auto-start Growl if it isn't already started.
Michael Aaron Safyan
I'm using growlnotify to send the notifications, because it's easy to use in a bash script. Is that what you meant the by Growl framework? Unfortunately, growlnotify won't auto-start Growl if it isn't already running.
adam n