Aylur / ags

A customizable and extensible shell
GNU General Public License v3.0
2.26k stars 116 forks source link

SysTray help: Using Slack with Systray shows a warning message "Could not find the icon 'Slack1_23' #146

Closed rodrigoramos closed 12 months ago

rodrigoramos commented 1 year ago

Hi, there!

I'm running Ags on Ubuntu/Sway and everything is working fine besides de system tray with Slack. When there is no unread message, Slack would show its icon without any difference. But as soon as I received a new message, it should show its icon with a small red ballon on the right bottom space (like this https://helpdeskgeek.com/wp-content/pictures/2020/03/slack-desktop-tray-features.png) but red instead of green-ish).

In the AGS log a received the following message:

com.github.Aylur.ags:500158): Gtk-WARNING **: 14:50:00.836: Could not find the icon 'Slack1_23'. The 'hicolor' theme
was not found either, perhaps you need to install it.
You can get a copy from:
    http://icon-theme.freedesktop.org/releases

It's important to say, that I do have the hicolor theme installed (through apt) :

$ apt list hicolor*
hicolor-icon-theme/jammy,jammy,now 0.17-2 all [instalado]

What am I missing? Is there anything related to some specific icon theme?

Some Notes (that could be OR not be releated):

Aylur commented 1 year ago

How is Slack installed? Might be something with Nix, otherwise I have no idea what could cause this. You are assigning TrayItem.icon to an Icon.icon right?

rodrigoramos commented 1 year ago

The Slack was installed using apt. And yes, I'm assigning TrayItem.icon to a Icon.icon. That's my code for it:

const SysTray = () =>
  Widget.Box({
    connections: [
      [
        SystemTray,
        (self) => {
          self.children = SystemTray.items.map((item) =>
            Widget.Button({
              child: Widget.Icon({ binds: [["icon", item, "icon"]] }),
              onPrimaryClick: (_, event) => item.activate(event),
              onSecondaryClick: (_, event) => item.openMenu(event),
              binds: [["tooltip-markup", item, "tooltip-markup"]],
            })
          );
        },
      ],
    ],
  });

Besides that, I noticed that I soon as I start the AGS the icon tray works properly. But when it does change its status, I got the broken icon.

I'll try to inspect better the icon changes.

rodrigoramos commented 1 year ago

Hi, @Aylur !

I was able to pinpoint the problem. It looks like that Slack (maybe any electron based apps?) is using temporary Icon Themes and when the icon changes, the IconThemePath also changes. I noticed that when I was debugging the iconName keeps changing.

So, in order to fix it, I appended on Systray service, method _refreshAllProperties, inside of call method callback the follow lines:

if (this._proxy.IconThemePath) {
    if (!this._iconTheme) this._iconTheme = Gtk.IconTheme.new();
    this._iconTheme.set_search_path([this._proxy.IconThemePath]);
}

Making the final _refreshAllProperties method looks like:

  _refreshAllProperties() {
      this._proxy.g_connection.call(
          this._proxy.g_name,
          this._proxy.g_object_path,
          'org.freedesktop.DBus.Properties',
          'GetAll',
          new GLib.Variant('(s)', [this._proxy.g_interface_name]),
          new GLib.VariantType('(a{sv})'),
          Gio.DBusCallFlags.NONE, -1,
          null,
          (proxy, result) => {
              const variant = proxy?.call_finish(result);
              if (!variant)
                  return;
              const [properties] = variant.deepUnpack();
              Object.entries(properties).map(([propertyName, value]) => {
                  this._proxy.set_cached_property(propertyName, value);
              });

             // THAT'S THE NEW CODE
              if (this._proxy.IconThemePath) {
                  if (!this._iconTheme) this._iconTheme = Gtk.IconTheme.new();
                  this._iconTheme.set_search_path([this._proxy.IconThemePath]);
              }
              // END OF THE NEW CODE

              this._notify();
          },
      );
  }

How should we proceed?

Aylur commented 1 year ago

that would seem to solve the issue, you should open up a PR