Tuesday, May 10, 2011

Unity: adding items to the dock

In this blog post I will outline a way to add new items to the dock in Unity.

Unity is a new graphic shell for the latest Ubuntu; Nauty Narwal. One of the more prominent features is a docking area.

In this docking area icons for running applications appear. You can decide to keep the icon as a launcher for the application. This feature is nicely integrated with the software center. Whenever new software is installed it will write a desktop file to /usr/share/applications/. This file describes how the menu-item will appear on the dock.

The only downside is that not all software is installed via the software center. One of the reasons is that the software center repositories hold older versions. For example the version of eclipse found in the repository is 3.5.2 (Galileo). At this moment the latest version of eclipse is 3.6 (Helios).
Software which is not installed via the software center does not readily appear on the dock. The reason is the missing desktop file. The rest of the blog post describes how to provide a custom desktop file.

I found the following site helpful. There is a more formal specification of the Desktop Entry Specification. A quick overview is given at anatomy-of-a-desktop-file.

The following steps create a launcher for an application which is not installed via the software center.

  1. Create a desktop file for the application
  2. Place the desktop file in ~/.local/share/applications/
  3. [Optionally] Drag the desktop file onto the dock

Create a desktop file for the application
There are various routes to creating a desktop file. One can create a desktop file from scratch, or copy and modify an existing one. A great place for inspiration are the desktop files in /usr/share/applications.
Below is an example of a desktop file. I created it to launch Eclipse. Paths mentioned are specific for my system and can be changed. The shortcut groups defined at lines 13, 15 and 20 appear when you right-click the icon.

[Desktop Entry]
Name=Eclipse Helios
Comment=Start the awesome Eclipse IDE


[Choose Shortcut Group]
Name=Choose workspace

[Workspace Shortcut Group]
Exec=/home/dvberkel/bin/eclipse/eclipse -data /home/dvberkel/workspace

Place the desktop file in ~/.local/share/applications/
Unity is looking for custom desktop files in the ~/.local/share.applications directory. It could be that Unity should be restarted before changes are picked up. This can be accomplished by issuing the following command: unity --replace.

[Optionally] Drag the desktop file onto the dock
By dragging the desktop file onto the dock it immediately can be used as a launcher. This option really worked well for me.

This concludes this blog post. In it I explained a means to provide a custom desktop file which gets picked up by Unity.


  1. I copied your file, changed my paths, verified the paths are all correct and got eclipse to show on the launcher. However, eclipse does not start when clicked. Ideas?

  2. Sorry, turned out to be a path issue.

  3. If all this is required to add a simple launcher, then indeed Unity is a huge step backwards in terms of usability and friendliness to a new user.