Monday, November 7, 2011

Add Eclipse to Ubuntu Unity lancher

Just like many other users of Ubuntu, I upgraded a few weeks ago to Ubuntu 11.10 "Oneiric Ocelot". Although the new Unity launcher takes a little time to get used to and has a few quirks, I still like it overall. It takes minimal amount of precious screen real estate and I find the use of the "Windows key" to start applications and find files very productive.

As a software developer I use Eclipse and I like to install some other tools manually under my home directory somewhere.

Add Eclipse to Launcher

To startup Eclipse, I just used the file manager and double clicked on the Eclipse executable. This gets tiresome really quickly. To integrate my self-installed Eclipse into the Unity launcher, you can create a configuration file that will tell the launcher how to startup a custom application like Eclipse.

Create a file with this contents and change the paths to where you installed Eclipse:

[Desktop Entry]
Comment=Eclipse JEE
Exec=/home/koert/software/eclipse-indigo-jee/eclipse
Icon=/home/koert/software/eclipse-indigo-jee/icon.xpm
Name=Eclipse JEE
Path=/home/koert/software/eclipse-indigo-jee
Type=Application
Terminal=false

Save this file as Eclipse.desktop in the .local/share/applications directory in your home directory.

Now, when you want to startup Eclipse, use the launcher (press the windows button) and enter Eclipse. The launcher should display the Eclipse icon, which you can use to start Eclipse. You will see the icon in the dock and you can keep this in the dock.

Start with specific workspace

When you use multiple workspaces, you can choose the workspace when Eclipse starts up by configuring items on the icon so that you can start a specific workspace.

You can add Shortcut Group items, which you must add to the X-Ayatana-Desktop-Shortcuts property.

This is an example with an option to choose a workspace and two options with specific workspaces:

[Desktop Entry]
Comment=Eclipse JEE
Exec=/home/koert/software/eclipse-indigo-jee/eclipse
Icon=/home/koert/software/eclipse-indigo-jee/icon.xpm
Name=Eclipse JEE
Path=/home/koert/software/eclipse-indigo-jee
Type=Application
Terminal=false
X-Ayatana-Desktop-Shortcuts=ChooseWorkspace;Workspace1;Workspace2

[ChooseWorkspace Shortcut Group]
Name=Choose workspace
Exec=/home/koert/software/eclipse-indigo-jee/eclipse
TargetEnvironment=Unity

[Workspace1 Shortcut Group]
Name=Privilege trunk
Exec=/home/koert/software/eclipse-indigo-jee/eclipse -name "Trunk" -data /home/koert/project/pretium/workspace
TargetEnvironment=Unity

[Workspace2 Shortcut Group]
Name=Privilege branche
Exec=/home/koert/software/eclipse-indigo-jee/eclipse -name "Branch" -data /home/koert/project/pretium/workspaces/branch-prod
TargetEnvironment=Unity

This saves me a little bit of time to startup Eclipse in the workspace that I want.

2 comments:

Leonardo said...

Nice How To. Thanks a lot.

Anonymous said...

Thank you for the guidance - much appreciated!