Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No tray icon on Linux (electron@^8) #21445

Closed
3 tasks done
vladimiry opened this issue Dec 9, 2019 · 35 comments · Fixed by #21904
Closed
3 tasks done

No tray icon on Linux (electron@^8) #21445

vladimiry opened this issue Dec 9, 2019 · 35 comments · Fixed by #21904

Comments

@vladimiry
Copy link

vladimiry commented Dec 9, 2019

Preflight Checklist

  • I have read the Contributing Guidelines for this project.
  • I agree to follow the Code of Conduct that this project adheres to.
  • I have searched the issue tracker for an issue that matches the one I want to file, without success.

Issue Details

  • Electron Version: 8.0.0-beta.4
  • Operating System: Linux (tested on: Manjaro LXDE, Ubuntu 19.04/19.10 Gnome Shell)
  • Last Known Working Electron version: 7.1.3

Expected Behavior

Tray icon created.

Actual Behavior

No tray icon created.

To Reproduce

https://github.com/vladimiry-playground/electron-quick-start-tray-issue

Screenshots

Additional Information

The issue has been partially fixed within #21154

CC @codebytere

@codebytere
Copy link
Member

codebytere commented Dec 9, 2019

Looks like it's Linux-specific - i was briefly concerned i missed something obvious in testing but it works fine on macOS when i run your repro. I'll try to look into this more but @zcbenz may also have more answers

@vladimiry
Copy link
Author

@codebytere thanks for a fast response.

PS The issue is also reproducible on Ubuntu 19.04, the original message got adjuted.

@codebytere
Copy link
Member

codebytere commented Dec 9, 2019

@vladimiry so it turns out the issue isn't quite that it doesn't get created, it's somehow just very small 😆

image

See that blue dot in the middle area to the left of slack? that's it. I'll keep digging since, you know, i don't think anyone is really aiming for teeny tiny icons

@vladimiry
Copy link
Author

@codebytere it might be so, but on Manjaro I can't even see that small dot. The original image has 128x128 size, https://github.com/vladimiry-playground/electron-quick-start-tray-issue/blob/master/icon.png, referenced to the tray here https://github.com/vladimiry-playground/electron-quick-start-tray-issue/blob/c068c1a20ceebf9bbcc543d51edacbfcbb47f5b1/main.js#L34

i don't think anyone is really aiming for teeny tiny icons

Yes please don't discriminate Linux users. The temporary fix could be in shipping tiny icons on all platforms, so there is no discrimination 😄

@vladimiry
Copy link
Author

so it turns out the issue isn't quite that it doesn't get created, it's somehow just very small

Can confirm such behavior on Ubuntu 19.04, a tiny subtle dot, and it's active - tray menu is working. On Manjaro I can't see the dot nor the functional menu (trying randomly clicking on the taskbar guessing transparent icon is somewhere there).

@MarshallOfSound MarshallOfSound removed their assignment Dec 10, 2019
@zcbenz
Copy link
Contributor

zcbenz commented Dec 11, 2019

The tray icon is implemented with Chromium's StatusIconLinuxDbus on Linux, it seems that they have broken something.

@vladimiry
Copy link
Author

Possibly related chromium's issue and commit (since 79.0.3923.0 tag/version).

@vladimiry
Copy link
Author

vladimiry commented Dec 12, 2019

As above-referenced chromimum issue says StatusNotifier/DBus support got added and something got removed. So I looked up things on the internet and got the tray icon well displayed but only on Manjaro XFCE so far (have not tried anything KDE based yet though, might be working well there):

  • Manjaro XFCE (possibly any distro that uses XFCE, like Xubuntu): xfce4-statusnotifier-plugin needs to be installed and then respective widget added to the panel. So xfce4-panel/built-in systray plugin named "notification area" is not sufficient anymore. Plugins work well if both activated, no conflicts noticed.
  • Ubuntu 19.04 Gnome Shell: KStatusNotifierItem/AppIndicator Support extension is supposed to handle the need as it seems to be supporting "status notifier/dbus" thing. But it's not welll displayed, there is still that subtle tiny dot instead of a full tray icon. So further digging is needed.

The side benefit I noticed is that the left/primary mouse click is being properly handled again after it's being broken starting from the @electron v3, see #14941. So now right click and left click are treated as a different action. Besides xfce4-statusnotifier-plugin is capable enough to optionally cancel this/proper behavior, so if someone needs it both right and left clicks still could trigger a single action - menu opening (it's good that the respective checkbox is turned off by default so we have right and left clicks working individually).

Since for now, there is no fully reliable way to guarantee that the tray icon is properly shown on Linux using electron v8+ I'm considering making "startMinimizedToTray" option disabled by default in ElectronMail. I will then add a note make sure you have got the tray icon displayed before enabling this option as you will be using tray icon to show/hide the app window near to the respective checkbox in the UI. That would not be the best move in terms of UX but it's better than if a user starts the app and doesn't see it started as there is no tray icon and so no way to get the app window displayed, basically no visible signs of the app got started.

@vladimiry
Copy link
Author

vladimiry commented Dec 12, 2019

Since I finally got the tray icon displayed on Linux in one case using @electron version 8 I played around for a while and noticed a few more issues which I'm going to place separately later if I will be able to narrow down the scope and create minimal reproducible projects for them. The following issues (based on preliminary observations):

  • It looks like if the async/delayed action is being triggered via the tray menu the app crashes/segfaults. Possibly any kind of actions, not only the async ones, not completely clear yet. If I trigger the same action not via the tray menu then there is no crush.
  • The tray menu items don't get updated dynamically as it worked in @electron version lower than 8, at least the visible property when I re-create the tray menu calling tray.setContextMenu(Menu.buildFromTemplate([...updated items...])).

These issues are off the topic here but wanted to highlight that in general, it's more than just tray icon not being displayed on Linux but the tray menu behavior is also changed.

@vladimiry
Copy link
Author

noticed a few more issues which I'm going to place separately later

#21499

@vladimiry
Copy link
Author

Kubuntu 19.10 (fresh install): icon well displayed.

@vladimiry
Copy link
Author

vladimiry commented Dec 14, 2019

I just resized the icon image from 128x128 down to 32x32 and it got displayed in full size on Ubuntu 19.10 Gnome Shell (fresh install + all updates). So there are ways to make the tray icon displayed on all the systems I tested the case (Ubuntu Gnome Shell, Kubuntu, Manjaro XFCE) and so I don't expect Electron will need to fix something about tray icon displaying but would prefer the issue to remain open for a while as many developers and users will face the same issue switching to Electron version 8.

To recap:

  • XFCE (Manjaro, Lubuntu, etc): xfce4-statusnotifier-plugin needs to be installed and respective widget placed to the panel. There is also https://gitlab.com/vala-panel-project/xfce4-sntray-plugin working plugin, alternative to xfce4-statusnotifier-plugin.
  • Gnome Shell (Ubuntu): tray icon image needs to have 32x32 or smaller size, o when you prepare the Linux package (pacman, deb, snap, appimage, rpm ,etc) make sure make sure 32x32 or smaller image is used for the tray icon. This point is no longer relevant as got fixed by @ckerr, see below messages.
  • KDE (Kubuntu): tray icon displayed out of the box, no tuning needed.
  • Cinnamon/Mint: "System Settings" -> "General" -> "Enable support for indicators" flag needs to be enabled. Some issues still possible, see Linux Mint/Cinnamon doesn't support StatusNotifier tray icons standard linuxmint/cinnamon#9176.

@codebytere
Copy link
Member

@vladimiry when adding a new issue, the GitHub issue tracker automatically surfaces relevant issues, so a new developer encountering this problem should be able to find this through those means. Given that you feel this issue has been resolved, and unless there's another need for this issue to remain open that i'm missing context on, for the sake of the issue tracker I think it may be better to close this out.

@vladimiry
Copy link
Author

Yes this issue is not a blocker, we figured out how to make the icon to be visible on all the popular kinds of Linux, so I'm closing it. There clearly was a major change on how the tray icon on Linux gets displayed, but this change seems to be coming from Chromium.

PS But #21499 is a real blocker for me even though it's not labeled as such.

@vladimiry
Copy link
Author

To whom it may concern. It turned out Electron is getting rid of DBus related tray icon implementation rolled out with @chromium update in Electron v8 in favor of previously used / GTK/appindicator approach, see #23674.

@p3x-robot
Copy link

yeah it is true and linux mint is upgrading the tray as well from v20.

@hovancik
Copy link

hovancik commented Jun 5, 2020

I am actually sorry to hear the StatusIconLinuxDbus is getting ripped of. For me, it solved many tray related issues and my app was finally working well on Linux ;/

@akontsevich

This comment has been minimized.

@bkmo
Copy link

bkmo commented Jun 13, 2020

Sorry to hear that the Dbus tray icon implementation is gone. It was great when it was implemented and the tray function finally worked as designed.

@hovancik
Copy link

hovancik commented Jun 14, 2020

Yep, tray tooltip was finally working for for me (XFCE, KDE) - which were broken before. Also, tray icon was finally looking good.

I am not sure why it was reverted, I have only had things started to work, and all it took was to install some extra packages mentioned in this thread to make new implementation to work. (#21445 (comment)).

Seems pretty unreasonable to go back to old implementation when new was working better and all it took was some extra package to install...

@akontsevich
Copy link

I think the problem is they just do not use features they are developing and therefore do not understand functionality state and reverting 100% working things according to strange or outdated bug reports.

@squalou
Copy link

squalou commented Jun 15, 2020

IMHO, there are plenty DE out there, each implementing one or another one so-called 'standard' to deal with the systray paradigm. This is a mess, yet this is real life.

Why electron can't keep both implementation instead of these violent switches bothers me.

(I mean : it's electron that pretends to address portability to all OS's and OS flavours, it's not an easy task, but that's what the project is about).

@calidion
Copy link
Contributor

Tray is still not working with electron 9.1.1 on Ubuntu 18.04

@mooocer
Copy link

mooocer commented Aug 25, 2020

I wrote the following code for my main process:

const iconPath = path.join(__dirname, 'iconTemplate.png');
let tray = null;

app.whenReady().then(() => {
    tray = new Tray(iconPath);
    tray.setToolTip('Alarm');
})

I didn't add the context menu because I had no use. Though I tried adding just in case it was required but it still didn't work. I am not using any rendering process either.

I am using auto-launch package as well.

Here's how my tray looks:

Screenshot from 2020-08-25 14-47-20

I tried the tray demo from electron-demo-api and the tray icon appears for the demo, so I am pretty sure it's not an OS problem. Similar StackOverflow question. Any ideas on how to fix it?

@calidion were you able to get it working?

@DotoPototo
Copy link

Tray is still not working with electron 9.3.0 on Mint 20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.