Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

When launching java programs (like IntelliJ IDEA and Crashplan) in Natty's Unity launcher, duplicate icons are shown (see image). For IntelliJ I created the .desktop file, for Crashplan the .desktop file is supplied with the application. Is there something that can be changed in the .desktop files (or somewhere else) that can prevent this from occurring? I couldn't find a bug report for unity itself but programs like Gnome-Do/Docky have bug reports and had to make internal changes to their applications to prevent this.

Duplicate Icons In this image the 1st icon is the one created from the .desktop file and the second icon is after launching it. Second icon disappears when closing the application.

Custom IntelliJ .desktop file

#!/usr/bin/env xdg-open
[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Icon[en_US]=/opt/idea/bin/idea128.png
Name[en_US]=IntelliJ IDEA
Exec=/opt/idea/bin/idea.sh
Name=IntelliJ IDEA
Icon=/opt/idea/bin/idea128.png
StartupNotify=true

Crashplan provide .desktop file

[Desktop Entry]
Version=1.0
Encoding=UTF-8
Name=CrashPlan
Categories=;
Comment=CrashPlan Desktop UI
Comment[en_CA]=CrashPlan Desktop UI
Exec=/usr/local/crashplan/bin/CrashPlanDesktop
Icon=/usr/local/crashplan/skin/icon_app_64x64.png
Hidden=false
Terminal=false
Type=Application
GenericName[en_CA]=
share|improve this question
    
I experience a similar issue when launching Minecraft in Unity –  Marco Ceppi May 5 '11 at 12:37
2  
Thanks God the problem gets affecting mainstream users (it used to be a problem for AWN and other dock enthusiasts only) finally. I hope Java (and not only Java) applications developers will consider fixing this now. By the way, Eclipse seems to have no such a problem, while I've never managed to fix this for MySQL Workbench and OpenOffice.org (tried when I was using AWN, before LibreOffice has emerged) . –  Ivan Nov 3 '11 at 11:25
    
The problem is about applications to use stupid not-identifying WM_CLASS names as far as I can remember. –  Ivan Nov 3 '11 at 11:33
    
If there there was no such a problem, I would for sure use Unity or AWN. But so far as not every application supports them perfectly, I prefer a traditional taskbar (because I hate half-solutions). –  Ivan Nov 3 '11 at 11:53

6 Answers 6

up vote 34 down vote accepted

Add a StartupWMClass string into your .desktop file. Use xprop command to get this class. For example :

$ xprop|grep WM_CLASS
 WM_CLASS(STRING) = "sun-awt-X11-XFramePeer", "java-lang-Thread"

$ cat /usr/share/applications/PHPStorm.desktop | grep StartupWM
StartupWMClass=sun-awt-X11-XFramePeer

More deatils in this thread (this about AWN, but works for Unity too)

share|improve this answer
1  
This works great for Crashplan StartupWMClass=CrashPlan but IntelliJ needed a little more convincing. I had to use info from this (blog.jteam.nl/2011/01/09/…) to get it working properly. –  Tim May 6 '11 at 1:51
    
As a small aside to update IntelliJ I modified the idea.vmoptions not the idea.sh script directly. Add -javaagent:agent.jar=IntelliJ_IDEA to the file. –  Tim May 6 '11 at 2:00
1  
With IntelliJ 11 the agent.jar is no longer necessary. StartupWMClass=jetbrains-idea –  Tim Dec 7 '11 at 2:58
    
And jetbrains-idea-ce for the Community Edition. PS, thanks a bunch Tim, 451F. –  Synesso Apr 22 '12 at 12:09
2  
@Ivan: you don't have to use both, you can use either one. So if jetbrains-idea is the unique one, the one you want, use it instead of sun-awt-X11-XFramePeer –  MestreLion Jun 30 '12 at 13:55

For Intellij Idea 11 under Ubuntu 11.10 is necessary to add at the idea's .desktop file following line:

StartupWMClass=jetbrains-idea
share|improve this answer

I was able to fix this for SQLDeveloper, which is a java program:

Using xprop (and then clicking on the SQLDeveloper window), I found the following line of output:

WM_CLASS(STRING) = "sun-awt-X11-XFramePeer", "oracle-ide-boot-Launcher"

Based on the comments found above and in https://bugs.launchpad.net/unity/+bug/757991, I added the following line to my local sqldeveloper.desktop file:

StartupWMClass=oracle-ide-boot-Launcher

share|improve this answer
    
In SQLDeveloper version 4 WM_CLASS changed to "sun-awt-X11-XFramePeer", "oracle-ide-osgi-boot-OracleIdeLauncher", so the .desktop parameter should changed to : StartupWMClass=oracle-ide-osgi-boot-OracleIdeLauncher –  Pisu Jun 23 at 7:06

I've documented the fix for Eclipse 4.x and 3.x here.

This solution is for glx-dock aka Cairo-dock but works for all task bars relying on WM_CLASS.

In the case of eclipse, the launch is a two step process as well.

        enter image description here

Basically, what you need to do is to identify Eclipse branding plugin.xml applicable to your Eclipse version and modify the application name property. When the workbench main windows is created, Jface will call the SWT Display.setName and this will set you WM_CLASS. If this is the declared WM_CLASS for your launcher, then running instances will find their dock launcher.

Don't forget to do eclipse -clean on the first time.

Tabbing through is also much improved.

enter image description here

share|improve this answer

IntelliJ IDEA is started by a script ($IDEA_HOME/bin/idea.sh). When its launcher is clicked, the script is executed, which starts a java executable and immediately exits. Unity notices that the application you started (the script) has already exited - that's why there is no indicator on the first IDEA icon. However, there is an other (from the executable started by the launcher) application running at the moment - and that's why the second IDEA icon is shown.

I hope the fix for this behavior will be implemented soon - but it is not a very straightforward one. It would have to involve a hand-maintained list associations between windows and launchers they should be associated with.

share|improve this answer

For CrashPlan, you can try moving your app file CrashPlan.desktop to /usr/share/applications. Only apps that live there can be locked into the launcher.

sudo mv ~/Desktop/CrashPlan.desktop /usr/share/applications/.

Then try using the dash to run CrashPlan.

You might be able to do something similar with IntelliJ IDEA, but since it's running a script, I'm not sure if it will work correctly.

share|improve this answer
    
I have both .desktop files in ~/.local/share/applications and don't have any issues locking them to the launcher. I am assuming that you mean available to be launched from Launcher but not yet launched when you say locked... –  Tim May 5 '11 at 11:23
    
Hm. I'm not able to place them in the launcher. I made mine with alacarte (Menu Editor). Maybe it's because I have ~/.local linked to somewhere else... Do your apps show the running triangle (left side) and the active triangle (right side)? –  idbrii May 5 '11 at 15:38
    
For the "launched" version of the icon, yes. You can see the running triangle in the first shot. I did some more research and think I have a working workaround for the duplicate icons. Will post an answer here. –  Tim May 6 '11 at 1:25
    
@451F beat me to the answer, I added a bit to his answer in my comments on how to get IntelliJ to work better. –  Tim May 6 '11 at 2:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.