How to add custom icons to Gnome shell tray in Wayland environment

I used Wayland to start gnome-shell. I wrote a test applet. The main function of this test program is to display icons in the tray, but it has no effect. There is nothing in the tray.
There is no problem with xorg. What should I do and what method should I use to display icons in the tray
This is my test code

#include <libappindicator/app-indicator.h>
static GtkActionEntry entries[] = {
  { "Quit",     "application-exit", "_Quit", "<control>Q",
    "Exit the application", G_CALLBACK (gtk_main_quit) },
};
static guint n_entries = G_N_ELEMENTS (entries);

static const gchar *ui_info =
"<ui>"
"  <popup name='IndicatorPopup'>"
"    <menuitem action='Quit' />"
"  </popup>"
"</ui>";

int main (int argc, char **argv)
{
    GtkWidget *indicator_menu;
    GtkActionGroup *action_group;
    GtkUIManager *uim;
    GError *error = NULL;
    AppIndicator *indicator;

    gtk_init (&argc, &argv);

    indicator = app_indicator_new ("simple-clock-indicator",
            "emblem-synchronizing",
            APP_INDICATOR_CATEGORY_APPLICATION_STATUS);


    /* Menus */
    action_group = gtk_action_group_new ("SimpleActions");
    gtk_action_group_add_actions (action_group,
                                entries, n_entries,
                                indicator);

    uim = gtk_ui_manager_new (); 
    gtk_ui_manager_insert_action_group (uim, action_group, 0);

    if (!gtk_ui_manager_add_ui_from_string (uim, ui_info, -1, &error)) {
        g_message ("Failed to build menus: %s\n", error->message);
        g_error_free (error);
        error = NULL;
    }

    app_indicator_set_status (indicator, APP_INDICATOR_STATUS_ACTIVE);

    app_indicator_set_title (indicator, "SimpleClockTitle");

    indicator_menu = gtk_ui_manager_get_widget (uim, "/ui/IndicatorPopup");
    app_indicator_set_menu (indicator, GTK_MENU (indicator_menu));

    gtk_main ();

    return 0;
}

gnome-shell doesn’t support system tray icons, so you must be using an extension. Hence I believe we can’t be of much help here, as if your extension doesn’t work well you’re probably better either opening an issue over to the extension’s issue tracker or asking in one of their chat (IRC/matrix/whatever).

1 Like

That’s odd; here the GtkStatusIcon, appindicator and other doesn’t work on standard gnome-shell even on xorg. You have to install an extension for it.

You can try installing the topicons-plus (https://github.com/phocean/TopIcons-plus) or, do like myself and create your own extension for this (https://github.com/PerryWerneck/dbstatusicon).

1 Like

Force the X11 backend in the client:

 gdk_set_allowed_backends ("x11");

There are hacks in place to make XEmbed work in the wayland session (with any of the top-icons extensions), but GTK’s support is limited to the X11 backend.

1 Like

Thank you for your reply. I found a way to use this extension (extension) to display custom icons on xorg and Wayland

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.