System tray icons: some program icons do not appear anymore

Hello, I am using Ubuntu Unity since many years, currently with Ubuntu 22.04.2 LTS. (I installed Unity to the standard version of Ubuntu from the Ubuntu repositories so currently I am using Unity 7.5.1.)

Problem is: The system tray icons are missing for about halve of my programs that do create and use a tray icon. Some examples of programs that should have a tray icon but it’s not visible with Unity desktop are: VirtualBox, Signal, Heroic Games Launcher, and a few more.

I know that at least the tray icons of VirtualBox and Signal were working fine with Unity about a year ago. Then something changed.

I had the same issue with Slack, which is an Electron based app like Signal, I believe.

The workaround is to start the app with XDG_CURRENT_DESKTOP unset, or exactly set to “Unity7”.
(notice the space after the equals sign, which is intentional)

WARNING: Do not try to alter the XDG_CURRENT_DESKTOP environment variable globally (or at login via ~/.profile or .bashrc etc.) or else you will have dangerous consequences such as OOM errors and leaving you with dysfunctional desktop. Leave the global one set as it is to the default value “Unity:Unity7:ubuntu”.

In my case, to avoid having to start the app from command-line with the environment variable overridden every time, I just override the respective app’s .desktop file from my home directory (which is what is responsible for displaying the app’s icon in our launcher), like so:

$ cp /usr/share/applications/slack.desktop ~/.local/share/applications/
$ sed -i 's#Exec=/usr/bin/slack#Exec=env XDG_CURRENT_DESKTOP=Unity7 /usr/bin/slack#' ~/.local/share/applications/slack.desktop

Therefore, when clicking the app’s icon from the launcher, Slack would start with the env variable XDG_CURRENT_DESKTOP set as it expects, and therefore the tray icon would show :slight_smile:

Currently tested working on Ubuntu Unity 23.04.


Hello @tamer-hassan this is interesting. I tried that, it works for Signal (Snap version) when I start with
XDG_CURRENT_DESKTOP=Unity7 signal-desktop

Not working perfectly for Heroic (Flat version) started with
XDG_CURRENT_DESKTOP=Unity7 flatpak run com.heroicgameslauncher.hgl
A tray icon is created and is functioning but it shows a missing image/default image.

Working for Discord (installed from .deb package) started with

Not working for VirtualBox (installed from Ubuntu repositories) - no tray icon visible. It should have a tray icon, afaik.

I am not sure if this is the best way, to detect and modify all programs, also because it does not seem to work with all programs. What could be a general solution to make all tray icons work again at once?

AFAIK VirtualBox doesn’t have tray icon. To verify, I installed virtualbox-qt package via apt in Kubuntu 23.04 on another laptop, and upon running it and minimizing it, it goes to the taskbar but no tray icon. And upon closing it, the application is terminated, not docked to the tray. Also there were no option in preferences about tray icon. So if in KDE it doesn’t have tray icon, then in Unity it won’t have tray icon either.

Again, as I said, the issue is with Electron only… Slack, Signal, Discord, all are Electron-based apps.
I have now raised issue on Electron for a fix: [Bug]: Tray icon missing on Ubuntu Unity 22.04 & 23.04 etc. · Issue #38979 · electron/electron · GitHub

Turns out Heroic (Linux Game) is also electron based

The reason you’re probably getting missing image/default image for the tray icon, is because the Icon is not defined via the .desktop file, as I recommended in my first reply above. Perhaps because you started it only from command line with the env var trick only.
Try by overriding the .desktop file as I recommended above, and make sure the desktop file contains a Icon=/usr/share/pixmaps/heroic_icon_name_here.png

Thank! Yes indeed, until now I only tested starting from command line only.

The permanent solution works for Signal too. Because it’s a snap I had to copy the desktop file from
cp /var/lib/snapd/desktop/applications/signal-desktop_signal-desktop.desktop ~/.local/share/applications/
Then, because I am not familiar with sed I opened the new desktop file with a text editor and added XDG_CURRENT_DESKTOP=Unity7 to the Exec env setting, it now looks like this:

Exec=env BAMF_DESKTOP_FILE_HINT=/var/lib/snapd/desktop/applications/signal-desktop_signal-desktop.desktop XDG_CURRENT_DESKTOP=Unity7 /snap/bin/signal-desktop --no-sandbox %U

Similar for Heroic Games Launcher as a Flatpak install:
cp /var/lib/flatpak/app/com.heroicgameslauncher.hgl/current/active/export/share/applications/com.heroicgameslauncher.hgl.desktop ~/.local/share/applications/
Then added env XDG_CURRENT_DESKTOP=Unity7 to the Exec options, it now looks like this:

Exec=env XDG_CURRENT_DESKTOP=Unity7 /usr/bin/flatpak run --branch=stable --arch=x86_64 --command=heroic-run --file-forwarding com.heroicgameslauncher.hgl @@u %u @@

I also tried adding an icon line. But the tray icon still is “missing image”. The program icons in dash and starter are fine even without the icon path in the desktop file.
The icon could be found here: /var/lib/flatpak/app/com.heroicgameslauncher.hgl/current/active/export/share/icons/hicolor/128x128/apps/com.heroicgameslauncher.hgl.png

For Discord, I copied this:
cp /usr/share/applications/discord.desktop ~/.local/share/applications/
and edited the file with this Exec line:

Exec=env XDG_CURRENT_DESKTOP=Unity7 /usr/share/discord/Discord

But I also had to make the file executable before it would work.

About VirtualBox: I’m sorry, It’s one of those programs where I’ve often missed a tray icon, but I guess it never officially had one.

However, it has the impression on me that this can only be a temporary solution. If a programs desktop starter is changed by updates, maybe with a new icon design or other execution arguments, the changes will be overwritten by my desktop files in ~/.local/share/applications when I run the program and it may not work properly. If uninstalled, I have to remove the files manually.

Anyway, if I come across other programs whose tray icons don’t appear with Unity, I will try this solution.

Once the issue is solved in Electron, and as the apps that use Electron get updated, this will all be fixed at once. [Bug]: Tray icon missing on Ubuntu Unity 22.04 & 23.04 etc. · Issue #38979 · electron/electron · GitHub

1 Like