Ubuntu – How to remove duplicate icons for “launched” java programs in the launcher

javalauncherunity

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]=

Best Answer

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)

Related Question