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

Add Dock items from the command line System
The file /System -> Library -> CoreServices -> Dock.app -> Contents -> Resources -> English.lproj -> default.plist appears to contain the default dock items that appear for a new user. Compared to what appears in a typical com.apple.dock.plist preferences file, the entry for each item appears much simpler. For example, for Safari:
 <dict>
    <key>tile-data</key>
    <dict>
     <key>file-data</key>
     <dict>
      <key>_CFURLString</key>
      <string>/Applications/Safari.app</string>
      <key>_CFURLStringType</key>
      <integer>0</integer>
     </dict>
    </dict>
   </dict>
This makes the defaults write command required to add an item to the Dock much easier to figure out. So in general, enter the command below in Terminal, substituting the full path to the item in the appropriate place. For applications, use persistent-apps. For files, use persistent-others. Here's the generic structure:
defaults write com.apple.dock persistent-apps -array-add '<dict>
<key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString
</key><string>/Path/to/the/Programme.app</string><key>_CFURLStringType
</key><integer>0</integer></dict></dict></dict>'
Note: The above needs to be entered as one long line with no additional spaces. It was broken here for narrower display width. The string above appears to be parsed correctly, and passes the plutil validity test. At some point, the file ends up being re-written in the usual format. The Dock will have to be restarted to see the effects; you can do that quickly with killall -HUP Dock in the Terminal.

Unfortunately, I don't know how to remove an entry from the Dock's default.plist file from the command line.
    •    
  • Currently 2.75 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (4 votes cast)
 
[27,290 views]  

Add Dock items from the command line | 6 comments | Create New Account
Click here to return to the 'Add Dock items from the command line' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Add Dock items from the command line
Authored by: Durandal on Aug 20, '04 03:28:49PM
There's no reason to mess with the default .plist in the Dock bundle. Create a new user (we'll call him UserA, for now). Log in as UserA and then populate the Dock as you want it to be for every new user. Now copy the file ~/Library/Preferences/com.apple.dock.plist (from UserA's home directory) to somewhere easily accessible (/Users/Shared/, for example). Now log in as an administrator, and execute the following command in the Terminal.
sudo cp /path/to/copied/com.apple.dock.plist /System/Library/User\ Template/English.lproj/Library/Preferences/
Naturally, replace the placeholder path directly after cp with the real location you copied com.apple.dock.plist to. If you copied it into /Users/Shared/, then you would do the following.
sudo cp /Users/Shared/com.apple.dock.plist /System/Library/User\ Template/English.lproj/Library/Preferences/
Alternatively, you could just do this without copying the .plist file at all (assuming you haven't changed the default path for home directories from /Users/).
sudo cp /Users/UserA/com.apple.dock.plist /System/Library/User\ Template/English.lproj/Library/Preferences/
Every new user created will now have that Dock preferences file copied to their ~/Library/Preferences directories, which the Dock will respect, so it won't copy its default .plist in there.

---
Damien Sorresso

[ Reply to This | # ]

Add Dock items from the command line
Authored by: Durandal on Aug 20, '04 03:30:38PM
Crap! Sorry. Replace that third terminal command with the following. I forgot the "Library" part of the path.
sudo cp /Users/UserA/Library/com.apple.dock.plist /System/Library/User\ Template/English.lproj/Library/Preferences/

---
Damien Sorresso

[ Reply to This | # ]

Add Dock items from the command line
Authored by: mm2270 on Aug 21, '04 09:56:19AM

Awesome! Thanks so much for this. I've been looking for an easy way to set up our soon-to-be new OS X systems with a default dock that is different than the usual default one when I set up the users on the workstations.

I'm going to try this out!



[ Reply to This | # ]
Add Dock items from the command line
Authored by: encro on Aug 23, '04 01:24:11PM

This is helpful if you write an application. You can then add your app to the users dock automatically from the installer process.



[ Reply to This | # ]
Add Dock items from the command line
Authored by: encro on Aug 23, '04 01:26:58PM

actually you should probably do this at user level rather than the default dock.



[ Reply to This | # ]
Add Dock items from the command line
Authored by: thespider on May 22, '08 11:30:01AM

This is a bad way to do things anymore, the dock should be populated via script. In the past, copying the whole dock worked. But not for people that have different apps on their dock. If your managing a lab, sure go ahead, but if your deploying an app to a bunch of computers already with docks, then try to use a script.



[ Reply to This | # ]