5

I am working with two different versions of Eclipse. Due to conflicts between the plugins I decided to install both of these versions separately, which works perfectly fine except one little issue. I am working with Ubuntu-Gnome (14.04 LTS) and I edited the .desktop file of one version like this:

[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Name=Custom Eclipse 
Icon=custom-icon
Path=/opt/custom-eclipse/
Exec=/opt/custom-eclipse/custom-eclipse
StartupNotify=true
StartupWMClass=custom-eclipse

Now, what bugs me is the following:

The application starts up with the custom name, WM_Class and icon as expected, yet, when the application has finished starting up these attributes change for some reason and it is grouped with the other eclipse installation by the gnome-shell.

If I enter xprop WM_CLASS in terminal and click on the window it returns WM_CLASS(STRING) = "Eclipse", "Eclipse".

edit: I just recently switched from a Unity desktop to a GNOME shell and using Unity the windows were not grouped together.

another edit: I updated my ubuntu version to 15.04 and my gnome-shell to 3.14.4 but unfortunately the problem remains. I am starting to think that this could only be fixed by editing the Eclipse source code...

  • What are bothe the .desktop file names (not the Name= line, but the actual file names)? where are they located? – Jacob Vlijm Jul 28 '15 at 12:59
  • they are both located in /usr/share/applications. one is called eclipse.desktop and one is called custom-eclipse.desktop – David Wright Jul 28 '15 at 13:02
  • Same behavior here with my both eclipse installations (Java, C++). xprop WM_CLASS gives WM_CLASS(STRING) = "Eclipse", "Eclipse" in both cases. But my running instances are not grouped. – A.B. Jul 28 '15 at 15:56
  • Just as information, but your method worked fine on another "duplicated" application I tested it on. There must be some kind of internal linking, causing your problem. – Jacob Vlijm Jul 28 '15 at 19:14
  • @JacobVlijm I suspect the same, since the startup window of Eclipse has the name, WM_CLASS and icon that I defined in the .desktop file, but after starting up the "running" window has changed properties. It might also have to do with the ubuntu or the desktop version since I recently switched from unity to a gnome desktop and in unity the windows were not grouped together. (on that note I might just add that to the question) – David Wright Jul 28 '15 at 19:29
  • Please vote to fix it https://bugs.eclipse.org/bugs/show_bug.cgi?id=500571 – Denis Jan 06 '22 at 08:55

3 Answers3

6

StartupWMClass does not change the actual application window class, but only tells the desktop manager what window class should use to identify the application window(s).

The problem is that Eclipse uses Eclipse as window class despite its version.

If you want to use more than one Eclipse version at once and have windows grouped correctly, with the ability to pin the application icon as favorite, you should edit the plugin.xml of package you are using.

For Eclipse Java EE IDE I succesfully edited the plugin.xml in

<eclipse-root>/plugins/org.eclipse.epp.package.jee_<current-version>

changing the properties

plugin/extension/product/@name
plugin/extension/product/property[@name=appName]/@value

(not sure wich one is enough) to whatever value you prefer. The same value you should put in .desktop file as StartupWMClass.

Alessio Gaeta
  • 161
  • 1
  • 5
  • unfortunately I did not find a plugin.xml file that contained these lines anywhere... – David Wright Mar 07 '16 at 06:54
  • Which version of Eclipse are you using? This method worked for me until Luna. Please note that I used XPath in my answer, so you will not find exactly the lines I wrote, but XML elements: <plugin><extensions><product name="Eclipse"> and <plugin><extensions><product><property name="appName" value="Eclipse" – Alessio Gaeta Mar 07 '16 at 09:10
  • The latest version is based on eclipse mars. I will look for similar lines in the plugin.xml files after lunch! – David Wright Mar 07 '16 at 10:40
1

I assume, it's not an answer but you could test my desktop files. Both files start Eclipse Mars in an Ubuntu 15.04 with a GNOME 3.16 environment.

With tis desktop files, I have two running instances which are not grouped.

cat ~/.local/share/applications/opt_eclipse_cpp.desktop

[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Name=Eclipse C++
Comment=Eclipse Integrated Development Environment
Icon=eclipse
Exec=/opt/eclipse-cpp/eclipse/eclipse
StartupNotify=true
StartupWMClass=Eclipse-CPP

cat ~/.local/share/applications/opt_eclipse.desktop

[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Name=Eclipse JEE
Comment=Eclipse Integrated Development Environment
Icon=eclipse
Exec=/opt/eclipse-jee/eclipse/eclipse
StartupNotify=true
StartupWMClass=Eclipse-Java

But

xprop WM_CLASS

gives

WM_CLASS(STRING) = "Eclipse", "Eclipse"

that's true

A.B.
  • 90,397
  • Thank you I will try that tomorrow as soon as I get to work. This reminded me that I had just recently switched to the gnome desktop from unity and in unity the windows were not grouped together. also I will check the gnome version. It might indicate that this could possibly an issue with the desktop version, although I suspected it to be something caused by Eclipse itself. – David Wright Jul 28 '15 at 19:36
  • Also, could you maybe check the WM_NAME attribute for me please? – David Wright Jul 29 '15 at 05:12
  • Sure, in 12 hours :\ – A.B. Jul 29 '15 at 05:13
  • I'm afraid I will be on a short holiday trip by then, but it looks like this issue might not be solved before that so I'm sure it would still be helpful when I come back next week:) – David Wright Jul 29 '15 at 05:19
  • I just updated my computer: now it runs ubuntu 15.04 and gnome-shell version 3.14.4, but the problem remains. I'm not sure if I want to add the GNOME staging PPA, is it stable? Also I tried your .desktop files, no luck either... – David Wright Jul 29 '15 at 08:11
  • I'm using GNOME 3.16 without any problems. And if the PPAs doen't work, you can purge them again. http://askubuntu.com/a/625250/367165 – A.B. Jul 29 '15 at 10:10
  • Little update: it seems that my colleague has the same issue on a KDE installation, whereas another colleague who has a unity desktop has the same situation as you have, @A.B. . Am starting to think that this situation could only be solved by modifying the Eclipse source code. Although it seems that it does not only have to do with the desktop. To be honest my knowledge about this is limited but I think that it has something to do with the window manager or display manager as well... – David Wright Aug 11 '15 at 05:55
1

StartupWMClass is only used to group windows with the same class name. You need to look at changing the class with the exec command if the program supports gtk options.

I've just been trying this with browsers running in app mode, currently class option is not working in chrome or chromium so I used Epiphany. Here's an example of my Trello desktop launcher.

[Desktop Entry]
Version=1.0
Type=Application
Exec=epiphany https://trello.com/ -a --profile=/epiphany/trello --class=trello
Icon=/MyIcons/trello.png
StartupNotify=true
Terminal=false
Name=Trello
StartupWMClass=trello
Generic
  • 11