mitchchn

#51424: fix: set XDG app ID and WM_CLASS based on normalized app name

Merged
Created: Apr 30, 2026, 6:25:11 PM
Merged: May 4, 2026, 3:12:27 PM
3 comments
Target: main

Description of Change

Fixes #51375.

This PR is an improvement to the logic in #49988, which set a default XDG App ID based on the app's executable path if a desktopName is not provided by the developer.

The exec name is usually good for compatibility but it has an important edge case: it cannot distinguish apps which do not rename their electron binary. This is a common practice for packages on Arch Linux which use "shared" copies of a single version of Electron as dependencies.

My solution is to restore the original logic to base the ID on productName/app.name, but to normalize the value so that it conforms to the FreeDesktop spec and so that it is likely to match the name of the .desktop file which would be created by packaging tools such as Forge/Fiddle. (Unfortunately there is no way to be 100% sure, since this is a packaging concern -- for best results, developers should set desktopName in package.json and not rely on a generated default value.) If it is not possible for Electron to derive a suitable name, it falls back to the executable name as in #49988.

In practice, most apps will have the same XDG app ID as in #49988, either because the normalized slug has the same value as the binary name, or because the developer is already setting desktopName properly.

String normalization can be messy, so I've added a table test for the kinds of values I've seen in Electron app names, as well as some names that cannot be normalized. The test did to not fit into any of the existing spec files because it is unit testing a non-public API, similar to the parse-features-string spec.

Finally, I made a change to set the same value for XDG app ID and WM_CLASS, which is a best practice to support both Wayland and X11. This fully solves #48391 and is a pre-req for #45866.

Checklist

Release Notes

Notes: Improved the way Electron determines the default XDG App ID and WM_CLASS on Linux for better platform compatibility if desktopName is not provided in package.json.

Backports

41-x-y
Merged
PR Number
#51480
Merged At
May 5, 2026, 9:44:44 AM
Released In
v41.5.1
Release Date
May 8, 2026, 11:00:22 AM
42-x-y
Merged
PR Number
#51479
Merged At
May 4, 2026, 7:57:46 PM
Released In
v42.0.0
Release Date
May 5, 2026, 2:07:06 PM

Semver Impact

Major
Breaking changes
Minor
New features
Patch
Bug fixes
None
Docs, tests, etc.

Semantic Versioning helps users understand the impact of updates:

  • Major (X.y.z): Breaking changes that may require code modifications
  • Minor (x.Y.z): New features that maintain backward compatibility
  • Patch (x.y.Z): Bug fixes that don't change the API
  • None: Changes that don't affect using facing parts of Electron