Desktop File WM Class Configuration#
On Linux, desktop environments like GNOME and KDE use StartupWMClass in .desktop files to bind a running window to its launcher icon. Element Desktop's .desktop file has historically shipped with a mismatched value, breaking window-to-launcher binding on GNOME/Wayland and causing a second, icon-less window to open instead of focusing the existing one.
Root Cause#
The .desktop file is generated by electron-builder, not stored as a static file in the repo. The build configuration lives in apps/desktop/electron-builder.ts, which passes variant.name as the Linux executable name. However, electron-builder's default behavior set StartupWMClass from variant.productName — "Element" for stable and "Element Nightly" for nightly — while the Electron process itself reported a lowercase WM_CLASS:
WM_CLASS(STRING) = "element", "element"
This case mismatch (capital E in the .desktop file vs. lowercase e in the running window) is enough for GNOME Shell to fail the match .
The discrepancy between productName and the actual window class is a known upstream bug in electron-builder (electron-userland/electron-builder#4974, #9103), addressed in electron-builder PR #9832, which shipped in electron-builder v26.15.0 .
Variant Configurations#
The two build variants and their relevant name fields are:
| Variant | name (variant.name) | productName |
|---|---|---|
| Stable | element-desktop | Element |
| Nightly | element-desktop-nightly | Element Nightly |
A second complication: even when StartupWMClass is set to variant.name, the stable build's actual WM_CLASS measures as "element" (no -desktop suffix), not "element-desktop". This was flagged by multiple reporters and reviewers on PR #33635 — the exact correct value for the stable channel still needs to be confirmed against a real xprop or Wayland app_id reading .
Current Status#
As of Element Desktop 1.12.22 (from packages.element.io), the shipped .desktop file still carries StartupWMClass=Element, which does not match the runtime window class . The repo is now on electron-builder 26.15.3 , which includes the upstream fix, but the .desktop file generation and whether it produces the correct StartupWMClass value for all variants should be verified in a built package.
Key open items from PR #33635 (which proposed an explicit StartupWMClass: variant.name override in the build config but was not yet merged at the time of reporting):
- Confirm the actual
WM_CLASS/ Waylandapp_idfor both stable and nightly builds in a real packaged install. - Verify electron-builder 26.15.x generates the correct value automatically before removing the explicit override.
User Workaround#
Create or override ~/.local/share/applications/element-desktop.desktop with the corrected value. The line that needs changing is:
StartupWMClass=element
(lowercase e). This takes effect after restarting the Shell session; no reboot needed .
Running sudo update-desktop-database after editing /usr/share/applications/element-desktop.desktop also works for system-wide fixes .
Key Files and References#
| Resource | Link |
|---|---|
| Build config (Linux section) | apps/desktop/electron-builder.ts L131–136 |
| Stable variant config | apps/desktop/element.io/release/build.json |
| Nightly variant config | apps/desktop/element.io/nightly/build.json |
| Upstream issue (element-web) | #33472 / #33920 |
| Fix PR (element-web) | #33635 |
| electron-builder upstream fix | electron-userland/electron-builder#9832 (v26.15.0+) |