dockutil 1.0 released

As a Mac sysadmin, I’ve had the need to manipulate the dock on hundreds of systems at a time.

I used to cobble together terrible shell scripts to do the job, but now thanks to plistlib and python, plist manipulation is really easy. I am releasing this utility free under the Apache 2.0 license. Hopefully some other sysadmins will find it useful.

dockutil is a command line utility for managing Mac OS X dock items.
It can add, replace, list, move, find, and delete dock items. It supports Applications, Folders, Stacks, and URLs. It can act on a specific dock plist or every dock plist in a folder of home directories.
It is compatible with Mac OS X Tiger and Leopard.

Download dockutil here.

Here is the usage information:

usage: dockutil -h
usage: dockutil --add (path to item) | (url) [--label (label)] [ folder_options ] [ position_options ] [ plist_location_specification ]
usage: dockutil --remove (dock item label) [ plist_location_specification ]
usage: dockutil --move (dock item label) position_options [ plist_location_specification ]
usage: dockutil --find (dock item label) [ plist_location_specification ]
usage: dockutil --list [ plist_location_specification ]

position_options:
--replacing (dock item label name) replaces the item with the given dock label or adds the item to the end if item to replace is not found
--position [ index_number | beginning | end | middle ] inserts the item at a fixed position: can be an position by index number or keyword
--after (dock item label name) inserts the item immediately after the given dock label or at the end if the item is not found
--before (dock item label name) inserts the item immediately before the given dock label or at the end if the item is not found
--section [ apps | others ] specifies whether the item should be added to the apps or others section

plist_location_specifications:
(path to a specific plist) default is the dock plist for current user
(path to a home directory)
--allhomes attempts to locate all home directories and perform the operation on each of them
--homeloc overrides the default /Users location for home directories

folder_options:
--view [grid|fan|list|automatic] stack view option
--display [folder|stack] how to display a folder's icon
--sort [name|dateadded|datemodified|datecreated|kind] sets sorting option for a folder view

Examples:
The following adds TextEdit.app to the end of the current user's dock:
dockutil --add /Applications/TextEdit.app

The following replaces Time Machine with TextEdit.app in the current user's dock:
dockutil --add /Applications/TextEdit.app --replacing 'Time Machine'

The following adds TextEdit.app after the item Time Machine in every user's dock on that machine:
dockutil --add /Applications/TextEdit.app --after 'Time Machine' --allhomes

The following adds ~/Downloads as a grid stack displayed as a folder for every user's dock on that machine:
dockutil --add '~/Downloads' --view grid --display folder --allhomes

The following adds a url dock item after the Downloads dock item for every user's dock on that machine:
dockutil --add vnc://miniserver.local --label 'Mini VNC' --after Downloads --allhomes

The following removes System Preferences from every user's dock on that machine:
dockutil --remove 'System Preferences' --allhomes

The following moves System Preferences to the second slot on every user's dock on that machine:
dockutil --move 'System Preferences' --position 2 --allhomes

The following finds any instance of iTunes in the specified home directory's dock:
dockutil --find iTunes /Users/jsmith

The following lists all dock items for all home directories at homeloc in the form: item(tab)path(tab)(section)tab(plist)
dockutil --list --homeloc /Volumes/RAID/Homes --allhomes

Notes:
When specifying a relative path like ~/Documents with the --allhomes option, ~/Documents must be quoted like '~/Documents' to get the item relative to each home

Bugs:
Names containing special characters like accent marks will fail

Contact:
Send bug reports and comments to kcrwfrd at gmail.

About these ads

26 Comments on “dockutil 1.0 released”

  1. Matt says:

    Awesome! This is an excellent idea.

  2. James says:

    Thank you. I’ve never had any luck manipulating the Dock using shell scripts (terrible or otherwise) – this utility is fantastic!

  3. [...] dockutil 1.0 released « Pattern Buffer: Awesome command line utility for manipulating the Dock in Mac OS X (tags: commandline coolsoftware tips) Post a Comment [...]

  4. IT Psycho says:

    Hello Kyle,

    I would like to add some CIFS shares automatically to a bunch of hosts, but didn’t recognize how to add shares with dockutil. Any hint?

    Regards

  5. Kyle Crawford says:

    This should work:

    dockutil –add smb://host.domain.com/Share –label Share

  6. IT Psycho says:

    That way it did show up as a URL link. I think that somewhere the automount-configuration has to be modified to get it done correctly, as existing shares show up as /Volumes// with some kind of binary ID in the plist.

  7. IT Psycho says:

    Edit:
    Should have been “/Volumes/server/share”

  8. Ben says:

    This is awesome.

  9. Hummaie says:

    So this a great little util, im wondering if someone might be able to help me on a little project, at the moment, i would like to change how it creates its property list, meaning how can i get the dock.app to create a com.apple.dock.plist with a diff name such as com.apple.dock2.plist? i dont want redirect what plist it uses, i want it to create a the plist with a diff name if it is unable to fine the default. Understand?

  10. Bulge says:

    Awesome, can’t wait to give it a try!

    Thanks

    Lach

  11. Joseph says:

    Just wondering if this also altered the dock in any of the User Template folders?

  12. Kerk says:

    Can it modify the User Template dock? I know that it doesn’t by default and I was messing around with homeloc for a little bit but couldn’t get it to work. Is there something I am missing?

    • Kyle Crawford says:

      No, sorry. There is a bug that prevents it from working on the User Template because there is a space in the path. I will fix in next version if someone else doesn’t fix it before me.

  13. Christian says:

    This tool is great and we started to use in Geneva (Switzerland) for our classes. 2 questions :

    – Is it working well in Snow Leopard (it seems) ?
    – The possibility to modify also the User Template dock will be very useful for us. Do you have an idea where you can fix it ?

    Many thanks for your great job

    Christian

    • Kyle Crawford says:

      Thanks Christian. I’m sorry I have not had time to do any updates.

      I think it is working fine in Snow Leopard even though it will produce some warnings.

      Sorry I can’t say when I will be able to do an update. If you or someone you know can do some scripting, the dockutil file is just python code and should be straightforward to modify.

  14. Christian Oihenart says:

    Hi,

    We have just discovered your great command line utility and we want to use it in our schools in Geneva, Switzerland. Have you had the time to fix it to work with User Template ? That will be very useful.

    Many thanks in advance

  15. Chris Waldrip says:

    For those wanting to change the User Template’s dock plist here’s an inelegant way…

    In your shell script use cp to move your dock.plist file from User Template to /tmp. Run dockutil and tell it to run on the specific file like this:
    dockutil –add /Applications/MyApp.app /tmp/com.apple.dock.plist
    Then have your shell script mv the file back to the User Template folder overwriting the original file.

    If you have multiple User Template files due to multiple languages, first make sure you really need all those languages, second just repeat the script for each lproj folder.

  16. Christian Oihenart says:

    An other way to act on User Template is to create a symbolic link to the User Template (by example ln -s /System/Library/User\ Template/French.lproj/ UserTemplate). Then, we use this link as target and it’s working well.

    Christian

  17. Adrian says:

    Excelleent! Found this tool very useful when I was upgrading the Adobe CS Suite on about 100 Macs.

  18. [...] all the CS4 dock icons for all users on each Mac. This was achieved using a great utility called dockutil. The only thing it doesn’t do is update the default [...]

  19. Johannes says:

    While trying the tool for the first time on my 10.6.6 Machine, i run into an Error:

    /bin/dockutil:22: DeprecationWarning: The popen2 module is deprecated. Use the subprocess module.
    import sys, plistlib, popen2, os, getopt, re

    The Item gets added, but the Error is confusing. Does the tool need an update?

    lg
    joe

  20. Brian Kerrigan says:

    Have an issue with some stations when using Dockutil.

    Keep getting “bin/bash: Line 1: dockutil: command not found”
    I seem to recall something about this when I first started using this great utility, but it evades me for the moment.

  21. Clayton says:

    I am getting the “dockutil: command not found” error also,
    how do I work around that?


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 29 other followers