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
GenericName=Eclipse
Comment=Start the awesome Eclipse IDE
Exec=/home/dvberkel/bin/eclipse/eclipse
Terminal=false
Type=Application
Icon=/home/dvberkel/bin/eclipse/icon.xpm
Categories=IDE;
StartupNotify=true
OnlyShowIn=GNOME;Unity;

X-Ayatana-Desktop-Shortcuts=Choose;Workspace;

[Choose Shortcut Group]
Name=Choose workspace
Exec=/home/dvberkel/bin/eclipse/eclipse
TargetEnvironment=Unity

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

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.

Monday, May 2, 2011

Learning Language Categories

In this blog post I will advocate to learn new language categories instead of new languages.

Every once in a while you find a post on a forum addressing the question which new language should one learn. Notable examples can be found by googling. Here is a sample:

In my opinion, growing as a developer is not about specific languages. If this was the case then why does nobody suggest C# if one knows Java or vice versa? Seldom is such an advice given. But if it is all about learning languages then this advice should surface as often as any other advice.

I think that language categories are more important then languages. One reason to learn a new language is to broaden your horizon. By seeing new solution to old problems your problem solving toolbox grows. Even if it is not possible to apply the language directly it often is possible to adopt the idea. By going beyond a language category barrier, the novelty and creativity with which problems can be solved grow enormously.

So the next time the question "Which language should I learn next" is asked, go ahead and advice to learn a new language category.

Using proper tags

while reviewing all my old posts in order to use the new Mathjax rendering engine (as mentioned here), I noticed that these posts do not always use proper html tags. I would rather rely on the basic blog layout to work for me.

Frankly it is unreliable. So I went back and redid them using proper tags. The most prominent change was the introduction of the humble <p> tag.

So you can expect a more consistent look and feel for my blog post of way back.