SystemTrayIconComponent does not work on Ubuntu

I’m on Ubuntu 18.04 LTS. juce::SystemTrayIconComponent does not work as expected. This is what it looks like on my machine (the system tray icon is the yellow smiley face):

Screenshot 2020-03-20 at 17.55.29

As you can see, it’s floating strangely in mid-air, somewhere near the upper left corner of the screen.

What I would have expected is that it would show up in the top menu bar in the upper right corner, just like the JetBrains Toolbox system tray icon (the purple thingy) does in the following screenshot:

Screenshot 2020-03-20 at 17.55.35

How can I achieve this behaviour with JUCE?

For reference, the exact same JUCE app works perfectly fine on Windows and Mac – look for the smiley:

Looking at the git blame for the juce_linux_X11_SystemTrayComponent.cpp file (the Linux implementation of juce::SystemTrayIconComponent), much of it was written between 7 and 9 years ago, and relies on the old, traditional system tray support that has, for the most part, been deprecated or removed from recent Linux distributions.

Ubuntu, in particular, developed the AppIndicator system that replaces system tray icons, and generally support for AppIndicators is available on most distros and desktop environments where the system tray is a relic of history. (The “X11” in the filename should also be a red flag — system tray icons aren’t available at all on Wayland, as they rely on X11 calls.) But without AppIndicator support, you’re pretty much stuck.

There are, however, libraries that take great pains to make system tray support transparently cross-platform again — dorkbox is one such library. That’s usually the best way to approach using the “system tray” in a cross-platform application.

1 Like

Er, I should’ve mentioned that dorkbox is a Java library, and therefore not immediately useful in JUCE code. It’s just meant as an example. There are probably C++ equivalents, but I don’t know of any offhand.

That’s interesting @FeRDNYC ! Would you say that the Windows and macOS versions of the JUCE SystemTrayIconComponent are good though?

Do you think it would be feasible to re-implement this JUCE component in C++ on top of the AppIndicator system?