46

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]=
Jorge Castro
  • 73,717
Tim
  • 563

8 Answers8

48

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)

451F
  • 596
9

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

StartupWMClass=jetbrains-idea
topr
  • 431
4

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
edwinksl
  • 24,109
Corey
  • 66
2

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

Delete
  • 728
0

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.

0

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.

idbrii
  • 3,162
0

None of the other answers worked for me, but in the end I actually found an even simpler solution.

Open up Intellij-Idea, and on the top bar find the tools dropdown menu. Then, select the Create Desktop Entry button. It'll create a properly working .desktop entry in your .local/share/applications folder, which should get recognized by whatever desktop environment you're using. It doesn't make a duplicate icon, and you can even change the icon if you want.

Unfortunately, using the nosplash argument brings back the duplicate icon problem, so I'm not sure how to fix that.

rusins
  • 161
0

After installing IntelliJ IDEA 2017.2.5 under Ubuntu 17.04 (with Numix icons) I had to change the line StartupWMClass=jetbrains-idea to StartupWMClass=jetbrains-idea-ce in the program's .desktop file so the duplicate icon would disappear.

I guess "ce" stands for Community Edition which I have, so I don't know why the value of this property in the .desktop file was originally not having the "ce" suffix.

tom
  • 183