Ubuntu – What does the StartupWMClass field of a .desktop file represent

desktop

I am working on this pre-existent .desktop file and I have a doubt:

The file content is:

[Desktop Entry]
#Icon=connect-data-space
Icon=XCloud
Categories=Utility;
Type=Application
#Exec=/usr/share/ConnectDataSpace/appl/launcher.sh
Exec=/usr/share/XCloud/appl/launcher.sh
Name[en_US]=Connect Data Space
#Name=Connect Data Space
Name=XCloud
Comment[en_US]=
Comment=
StartupNotify=true
Terminal=false
OnlyShowIn=GNOME;Unity;
StartupWMClass=ConnectDataSpace
Actions=CheckUpgrade

[Desktop Action CheckUpgrade]
Name=Verifica Aggiornamenti
#Exec=java -jar /usr/share/ConnectDataSpace/appl/lib/shellExtBridge.jar -checkupgrade
Exec=java -jar /usr/share/XCloud/appl/lib/shellExtBridge.jar -checkupgrade
OnlyShowIn=GNOME;Unity;

What exactly does the StartupWMClass field of this file represent?

Best Answer

Modern Linux desktop environments (Gnome 3, Ubuntu Unity, Docky) use the WMClass property to associate windows with the owning application. Many Java-based applications have the problem where the windows created by the application are not associated with the shortcut used to start the application (so the dock contains multiple copies of the same icon).

So the field called StartupWMClass is a string that defines in which class the application is grouped in the Unity Launcher at startup.

You can find out which WM_CLASS your window has got when you type in a terminal:

xprop WM_CLASS

and then click at the window. In case of the gnome terminal the output is as follows:

WM_CLASS(STRING) = "gnome-terminal", "Gnome-terminal"

So all windows with WM_CLASS "gnome-terminal" and "Gnome-terminal" are grouped together.

Related Question