Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Add login items via the command line UNIX
This is simple but handy command to add LoginItems (items that are executed after the user logs in) via the command line using the default tool. To add a normal startup item, use this syntax:
defaults write loginwindow AutoLaunchedApplicationDictionary -array-add \
'<dict><key>Hide</key><false/><key>Path</key><string>/path/to/item</string></dict>'
Of course, replace /path/to/item with the absolute path to whatever it is you want to open. Also, if you want the opened thing to hide itself when it opens, just change the word false, after the Hide key, to true. That's all there is to it.

[robg adds: Caution: If you form this command incorrectly, it's possible you could overwrite all of your login items -- backup the loginwindow.plist file before starting -- it's in your user's Library/Preferences folder. There's no similar easy way to remove an added item via the command line, since it's part of an array of values. You could just use pico or vi on the loginwindow.plist file, of course ... or once you have the GUI available, via the normal Login Items tab in the Accounts pane of System Preferences.]
    •    
  • Currently 1.71 / 5
  You rated: 1 / 5 (7 votes cast)
 
[20,907 views]  

Add login items via the command line | 2 comments | Create New Account
Click here to return to the 'Add login items via the command line' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Add login items via the command line
Authored by: juggularity on Mar 22, '05 11:28:11AM

According to the man page you can delete with the defaults command:
defaults [currentHost | -host hostname] delete [domain [key]]



[ Reply to This | # ]
Add login items via the command line
Authored by: ClassicUser on Mar 22, '05 01:13:18PM
According to the man page you can delete with the defaults command: defaults [currentHost | -host hostname] delete [domain [key]]
Yes, but it's extremely difficult to remove a single item from a DICT or ARRAY entry within that .plist - essentially, it's an "all or nothing" proposition.

Adding to such an array with "defaults write {domain} {key} -array-add {value list}" is fairly straightforward - but don't expect to be able to remove a given item the same way.

[ Reply to This | # ]