Skip to content

Wayland app_id should be normalized to match wm_class #48391

Closed

Description

@mitchchn

Preflight Checklist

Electron Version

38

What operating system(s) are you using?

Other Linux

Operating System Version

Fedora 42

What arch are you using?

x64

Last Known Working Electron version

No response

Does the issue also appear in Chromium / Google Chrome?

No

Expected Behavior

Apps should have the same wm_class (X11) and app_id (Wayland) by default. This allows desktop environments to look up the correct icons on both X11 and Wayland, based on a single .desktop file.

e.g.., an app with productName: "1Password" should have its wm_class and app_id both normalized to "1password" to correspond with a "1password.desktop" file.

It might also be a good idea to let developers specify the app_id and/or wm_class at runtime instead of relying on hard-to-understand semantics from fields in package.json.

Actual Behavior

Electron sets a lowercase wm_class but preserves the case when setting app_id, deriving both values from the same fields in package.json (productName or name). If the source value isn't already lowercase, this causes some icons not loading properly on Wayland in certain environments, e.g. KDE. An example is 1Password, which shows its icon in the taskbar icon but is unable to show it in the Alt-Tab switcher or window corner when running in native Wayland mode:

  • productName: "1Password"
  • derived wm_class: 1password
  • derived app_id: 1Password
  • desktop file: 1password.desktop
Image

Testcase Gist URL

No response

Additional Information

xdg documentation: https://wayland.app/protocols/xdg-shell#xdg_toplevel:request:set_app_id

Activity

  1. added theissue type on Sep 25, 2025
  2. moved this to 👀 Unsorted Items in 38-x-yon Sep 25, 2025
  3. nikwen commented on Sep 29, 2025

    @nikwen
    Member

    Thanks for filing this issue!

    We've also had other reports of icons not working: #45638

  4. mitchchn commented on Oct 4, 2025

    @mitchchn
    MemberAuthor

    For anyone who is interested, I found a workaround: set desktopName in package.json:

    "productName": "1Password",
    "desktopName": "1password.desktop"
    

    This sets the XDG app ID correctly to "1password".

    But I still think that Electron shouldn't be using the product name at all (especially if not sanitized) to determine the app ID: product names are supposed to be human readable, capitalized and have spaces, they aren't great IDs.

  5. mitchchn commented on Oct 7, 2025

    @mitchchn
    MemberAuthor

    Related: the XDG app ID and .desktop file aren't allowed to have spaces, but they're likely to be included in an app's product name:

    For applications, the part of the name of the desktop file before the .desktop extension should be a valid D-Bus well-known name. This means that it is a sequence of non-empty elements separated by dots (U+002E FULL STOP), none of which starts with a digit, and each of which contains only characters from the set [A-Za-z0-9-_]: ASCII letters, digits, dash (U+002D HYPHEN-MINUS) and underscore (U+005F LOW LINE).

    https://specifications.freedesktop.org/desktop-entry-spec/latest/file-naming.html?utm_source=chatgpt.com

    Ideally, out of the box, given productName: "Foo Desktop":

    1. Forge creates an appropriate .desktop file: foo-desktop.desktop with startup class foo-desktop
    2. Electron sets foo-desktop as both the XDG App ID and wm_class
    3. Electron and Forge continue to respect overrides provided via desktopName

    This would go a long way to fixing icon problems for apps.

  6. added
    status/confirmed
    on Oct 8, 2025
  7. moved this from 👀 Unsorted Items to 👍 Does Not Block Stable in 38-x-yon Oct 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    38-x-ybug 🪲platform/linuxstatus/confirmedwayland

    Type

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions