Identifying applications from windows to .desktop files
nalimilan at club.fr
Sun Feb 22 03:41:59 PST 2009
In the development of the new GNOME Shell we're facing a problem that
surprisingly does not seem to have been raised even if it's quite basic:
there is no standard way of identifying the application owning a given
We are now tracking applications usage to build stats and present the
user with the most used apps. For this, we identify windows with their
WM classes, and want to map this to a specific application, i.e.
a .desktop file.
There seem to be a breach there in the way we can identify apps. We have
the "Name" field that allows to show a proper name to the user; but it
does not correspond to the WM class. The "Exec" field can be used if we
get the command that was used to start the app owning a given window;
but that's a problem if we can use different command, and OpenOffice.org
can be started using "oobase" and used to edit text files.
For now, we're using the most obvious solution: we take the WM class,
put it in lower case, and we have the .desktop file name. This behaviour
is also used by GIO in GDesktopAppInfo, which has no other ways of
dealing with apps than "desktop ids" (from the reference):
> A desktop file id is the basename of the desktop file, including
> the .desktop extension. GIO is looking for a desktop file with this
> name in the applications subdirectories of the XDG data directories.
> GIO also supports the prefix-to-subdirectory mapping that is
> described in the Menu Spec.
This works really great for *most* apps. But this is AFAIK absolutely
non-standard. Indeed, OpenOffice.org (best example, but not the only
one) uses different .desktop file names among distributions, and this is
perfectly allowed. That breaks our little trick, and would force us to
adapt to every variant and apply ugly patches all the time. When I've
asked Ubuntu developers to "standardize" this name, they logically said
that nobody should rely on filenames to identify an app.
So what we're asking for is a way to uniquely identify an app all over
the desktop, from the window to the .desktop file and executable. This
can be useful in many cases. The simplest way to achieve that goal would
be to standardize what is de facto admitted, and require applications to
use a unique identifier for their .desktop file names. This identifier
should never change (between releases...). If we don't like the idea of
meaningful filenames, a new field can be added to .desktop spec.
Then to match windows to their apps identifier, we could require WM
classes to be equal to this identifier. I can't see any drawback to this
rule, which is already mostly respected and guarantees consistent
behavior in different matters. If this seems too restrictive, then a WM
property could be made mandatory, containing the app identifier. That
would be restrictive in the sense that it would require slowly modifying
all apps, and we could no rely on it before long...
To sum up, I can see two ways of solving the issue:
1) Enforce what is already the custom: no big modifications except for a
handful of "non-standard" apps (requires only a new paragraph in the
2) Add the concept of app identifier in a different way, which implies
- a new field in the Desktop spec
- possibly a new WM property for all windows
Thanks for reading this long case, I hope you can see how useful it
could be. We're really close to a standard behavior, so IMHO it's worth
a few lines in a spec!
More information about the xdg