Skip to content

[Bug]: Tray icon on Linux has chome id for all Electron applications (AppIndicator/StatusNotifierItem) #40936

Closed

Description

@pdf

Preflight Checklist

Electron Version

28.0.0

What operating system are you using?

Other Linux

Operating System Version

Arch Linux

What arch are you using?

x64

Last Known Working Electron version

22.x

Expected Behavior

For various desktop environments to function correctly, every registered AppIndicator must have a unique, stable ID attached to the StatusNotifierItem. Prior to the migration to StatusIconLinuxDbus implementation in #36333 the application name was used as the ID prefix.

Actual Behavior

All Electron applications use the same indicator ID value of chrome_status_icon_1, which breaks the functionality of desktop environments for managing tray icons like sorting, hiding, etc.

Testcase Gist URL

No response

Additional Information

See some examples of previous times this was fixed:

#5969
#15536 (comment)

Activity

  1. moved this to 👀 Unsorted Items in 28-x-yon Jan 16, 2024
  2. moved this to 👀 Unsorted Items in 29-x-yon Jan 16, 2024
  3. added
    blocked/need-repro
    on Jan 16, 2024
  4. electron-issue-triage commented on Jan 16, 2024

    @electron-issue-triage

    Hello @pdf. Thanks for reporting this and helping to make Electron better!

    Would it be possible for you to make a standalone testcase with only the code necessary to reproduce the issue? For example, Electron Fiddle is a great tool for making small test cases and makes it easy to publish your test case to a gist that Electron maintainers can use.

    Stand-alone test cases make fixing issues go more smoothly: it ensure everyone's looking at the same issue, it removes all unnecessary variables from the equation, and it can also provide the basis for automated regression tests.

    Now adding the blocked/need-repro Needs a test case to reproduce the bug label for this reason. After you make a test case, please link to it in a followup comment. This issue will be closed in 10 days if the above is not addressed.

  5. pdf commented on Jan 16, 2024

    @pdf
    Author

    @codebytere I'm not an Electron developer, so I'm not sure off-hand how to write an Electron application that registers a system tray - I observed this behaviour of Electron apps when implementing an SNI host.

    If it helps, here's the DBUS dialog when any Electron application registers a tray icon to the SNI host, and is queried for its SNI id property - every Electron application returns the same result (though the last digit will increase if they for some reason register multiple tray icons AIUI):

    method call time=1705437918.487533 sender=:1.456 -> destination=org.kde.StatusNotifierWatcher serial=49 path=/StatusNotifierWatcher; interface=org.kde.StatusNotifierWatcher; member=RegisterStatusNotifierItem
       string "org.kde.StatusNotifierItem-5-1"
    method call time=1705437918.487726 sender=:1.13 -> destination=org.kde.StatusNotifierItem-5-1 serial=18192 path=/StatusNotifierItem; interface=org.freedesktop.DBus.Properties; member=Get
       string "org.kde.StatusNotifierItem"
       string "Id"
    method return time=1705437918.487905 sender=:1.456 -> destination=:1.13 serial=50 reply_serial=18192
       variant       string "chrome_status_icon_1"
    

    But the multiple times this has been fixed in previous implmementations of SNI as mentioned in the original issue should serve as illustration enough of the issue, no?

  6. removed
    blocked/need-repro
    on Jan 16, 2024
  7. moved this from 👀 Unsorted Items to 👍 Does Not Block Stable in 29-x-yon Jan 17, 2024
  8. moved this from 👀 Unsorted Items to 👍 Does Not Block Stable in 28-x-yon Jan 17, 2024
  9. ZenithMonk commented on Mar 9, 2024

    @ZenithMonk

    Any updates on the issue ?

  10. 35 remaining items

  11. lordgreg commented on Jul 31, 2025

    @lordgreg

    Hi,

    most of the flathub apps on Linux that are using the electron as the app engine share the exact same issue.

    Thank you for your hard work electron devs!

  12. Reginald-Gillespie commented on Jul 31, 2025

    @Reginald-Gillespie

    most of the flathub apps on Linux that are using the electron as the app engine share the exact same issue.

    @lordgreg When you say most, are you using that as an expression, or because you have not tried them all, or literally? What I am asking is, do any apps that use electron not share the same issue? I would be curious how they managed it if so.

  13. lordgreg commented on Jul 31, 2025

    @lordgreg

    most of the flathub apps on Linux that are using the electron as the app engine share the exact same issue.

    @lordgreg When you say most, are you using that as an expression, or because you have not tried them all, or literally? What I am asking is, do any apps that use electron not share the same issue? I would be curious how they managed it if so.

    I am terribly sorry that I've formulated my sentence in the doubtful way. With most I mean all Electron-based Apps that I have used or been using.

  14. Damglador commented on Oct 25, 2025

    @Damglador
    Contributor

    Doing a bit of digging. Chrome sets seems to control properties of the entry in https://chromium.googlesource.com/chromium/src/+/HEAD/chrome/browser/ui/views/status_icons/status_icon_linux_dbus.cc which gets used in https://github.com/electron/electron/blob/main/shell/browser/ui/tray_icon_linux.cc but it probably doesn't touch the id, so chromium sets the default from PropertyIdFromId(NextServiceId()) which likely returns that chrome_status_icon_1, and increases the id only if there are multiple icons from the same app, doesn't even try to check if it's a duplicate of another app's id:

    std::string PropertyIdFromId(int service_id) {
      return "chrome_status_icon_" + base::NumberToString(service_id);
    }
    
    int NextServiceId() {
      static int status_icon_count = 0;
      return ++status_icon_count;
    }
    

    Now the only thing left is to figure out how to set that id from Electron with close to zero C++ skills.

  15. 0009-0009-1013-986X commented on Oct 25, 2025

    @0009-0009-1013-986X

    If it hasn't been mentioned yet, a downstream bug may exist at bugs.kde.org/show_bug.cgi?id=470840, with diagnosis.

  16. pdf commented on Oct 25, 2025

    @pdf
    Author

    Doing a bit of digging. Chrome sets seems to control properties of the entry in https://chromium.googlesource.com/chromium/src/+/HEAD/chrome/browser/ui/views/status_icons/status_icon_linux_dbus.cc which gets used in https://github.com/electron/electron/blob/main/shell/browser/ui/tray_icon_linux.cc but it probably doesn't touch the id, so chromium sets the default from PropertyIdFromId(NextServiceId()) which likely returns that chrome_status_icon_1, and increases the id only if there are multiple icons from the same app, doesn't even try to check if it's a duplicate of another app's id:

    std::string PropertyIdFromId(int service_id) {
      return "chrome_status_icon_" + base::NumberToString(service_id);
    }
    

    Now the only thing left is to figure out how to set that id from Electron with close to zero C++ skills.

    This has been fixed multiple times in the past, it just needs to do something there like:

    https://github.com/electron/electron/pull/6145/files#diff-dbb87d19c09dc890aec5a50b3ddd39bdbf5df4e479b6bc27269ffb6e499ec93eR39

  17. Damglador commented on Oct 25, 2025

    @Damglador
    Contributor

    So basically replace

    std::string PropertyIdFromId(int service_id) {
      return "chrome_status_icon_" + base::NumberToString(service_id);
    }
    

    in chrome/browser/ui/views/status_icons/status_icon_linux_dbus.cc with something like

    std::string PropertyIdFromId(int service_id) {
      return Browser::Get()->GetName().c_str() + base::NumberToString(service_id);
    }
    

    plus header for Browser using a patch

    I think that's the easiest fix. Though, might as well remove the id at the end if it's = 1. Testing this will be fun

  18. pdf commented on Oct 25, 2025

    @pdf
    Author

    Personally I'd use base::StringPrintf as the previous change did. For simplicity I'd probably just leave the numeric suffix always, end users rarely see it anyway.

  19. Damglador commented on Oct 27, 2025

    @Damglador
    Contributor

    I think I did it.

    Now it returns

          dict entry(
             string "Id"
             variant             string "tray-test_status_icon_1"
          )
    

    on my test app and Electron_status_icon_1 by default

    Compiling took like 2 days though

  20. JazzyJack357 commented on Nov 21, 2026

    @JazzyJack357

    I can reproduce a related problem on Ubuntu MATE with mate-indicator-applet + ayatana-indicator-application-service.

    Two Electron apps (Joplin, Claude Desktop) run at the same time. Both register a StatusNotifierItem with the same IconName ("status_icon_0") and differing IconThemePath (/tmp/org.chromium.Chromium.XXXXXX). Their Ids are distinct (Joplin_status_icon_1, Claude_status_icon_1), but the host resolves the icon only by name, so the app that started first wins and the second app shows the first app's icon.

    GetAll on the item (Joplin):
    IconName = 'status_icon_0'
    IconThemePath = '/tmp/org.chromium.Chromium.rqtOO9'
    Id = 'Joplin_status_icon_1'
    No IconPixmap property is exposed.

    Claude Desktop:
    IconName = 'status_icon_0'
    IconThemePath = '/tmp/org.chromium.Chromium.STdvvx'
    Id = 'Claude_status_icon_1'

    Closing one of the apps restores the correct icon of the other. Restarting the applet does not change it. Setting XDG_CURRENT_DESKTOP=Unity makes the app not register at all in this host.

    Versions: Joplin Electron <42.11.18>, Claude Desktop Electron <45.3.3>, Ubuntu MATE <26.04.1 LTS>, MATE Desktop Environment <1.28.2>

    Exposing IconPixmap, or using a per-app unique IconName (e.g. derived from the app name), would avoid the collision regardless of the host.

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

    28-x-y29-x-ybug 🪲platform/linuxstale-exempt

    Type

    No type

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions