Managing the Dock From the Command Line

Hi Everyone. As you can probably see the punctuality of my posts are becoming a bit of a running joke, one that I promise is not intentional!

To make up for it I found an interesting little gem a few months ago I thought I’d share, Dockutil.

First, lets get the required stuff out of the way. I didn’t write and I don’t own this little tool, that honour belongs to a ‘kcrawford’ who posted it up on github.com.

Second item is the usual disclaimer:

While the author has taken care to provide our readers with accurate information, please use your discretion before acting upon information based on the blog post. Amsys will not compensate you in any way whatsoever if you ever happen to suffer a loss/inconvenience/damage because of/while making use of information in this blog.

Right, lets get down to the good stuff!

So, what is it?

A very good question, Dockutil is a command line tool, written in Python that provides a command line method to modify (or manage) a user’s dock. Once downloaded and installed you can issue the following commands (for example) and they’ll have the matching results.

dockutil --add /Applications/iCal.app

This will add iCal to the dock, at the last position (next to the Trash) and in the current user’s dock only.

dockutil --add /Applications/iCal.app --after 'Time Machine' --allhomes

This will add iCal to the dock, but after Time Machine, and for all local users on the machine.

dockutil --add vnc://miniserver.local --label 'Mini VNC' --after Downloads --allhomes

As you can guess, this will add a VNC shortcut to the dock, called “Mini VNC” after the Downloads folder for each user account. Dockutil is clever enough to realise this should be added as a URL item, rather then an application shortcut and so does it automatically.

But I’m sitting right here. What’s wrong with the GUI?

Good point. What is the point? Well how about this:

You are not sitting in front of a user’s machine but instead are ssh’d in with no way to get a VNC connection. The end user is complaining about “I have deleted Mail out of my shortcut bar at the bottom!” If you have Dockutil installed, push out this command:

dockutil --add /Applications/Mail.app

Ta da! You’ve solved the problem, the end user has his Mail back and is a little perplexed on how you did it.

Everyone’s a winner!

Another use I have heard of (which is what drew my attention to Dockutil in the first place) was Casper. You can run a policy to install Dockutil, and then each following policy that installs a new application can have a Terminal command to add the application to the Dock. Nice, eh?

Where do I get it? How do I install it?

  1. Go to the download page on github
  2. Click on the most up to date version (currently “dockutil-1.1.2.pkg.dmg”).
  3. Download the DMG and open.
  4. Run the installer inside.
  5. Go have a cup of tea.

And there you have it. Enjoy!

Summary

I hope you enjoyed my little find and it can go someway to making your lives easier as Mac admins and support staff.

If I can’t promise to make my blogs punctual, the least I can do is find cool stuff to show off!

Any interesting or helpful tools you use?

Let us know in the comments below and I’ll try to respond to as many as I can.


Share this post online:


Leave a Reply