StartupWMClass will not change WM_Class of Eclipse IDE

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...


Solution 1:

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.

Solution 2:

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

Solution 3:

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