All those properties (pid, WM_CLASS, title) are replaced by snixembed. Not sure if its possible to easily redefine those values.
I need pid to get working left click on GTK apps with don't support this native. (https://github.com/MartinPL/Tray-Icons-Reloaded)
Thanks for your work.
refs: https://developer.gnome.org/shell/stable/shell-shell-tray-icon.html https://github.com/GNOME/gnome-shell/blob/20f4fc7c877472591cd77aeacb58645cf11f432a/src/shell-tray-icon.c https://specifications.freedesktop.org/systemtray-spec/systemtray-spec-latest.html#hints
I'm actually surprised snixembed runs at all under GNOME. Doesn't GNOME have its own StatusNotifierWatcher?
I looked into this for a bit, and it turns out that reliably implementing this will take surprisingly much effort, since apps like electron don't set the appropriate values on their StatusNotifierItem. More on that below, but why do you need this information? I've scanned through your code for a bit (and have no idea what most of it does), but it appears to me that you can send events to the icons right? Can't you just send a right click event to them when you get a left click event? Or is this not what you're trying to achieve?
Getting the pid information would be possible (through https://dbus.freedesktop.org/doc/dbus-specification.html#bus-messages-get-connection-unix-process-id), but I'm not sure if we can just advertise the icon on a different pid. The Gtk+ StatusIcon class we use now doesn't support it at least.
WM_NAMEcan be done (
set_name), but snixembed will have to get the correct name to set in some way. In the SNI spec, there is an Id and Title field, but electron (of course) sets neither of them to sensible values. (Title is empty and Id is always "chrome_status_icon_1"). There is also a WindowId property to get an associated window, but electron doesn't set that.
The only way to sort of fix this is to get the pid from a tray icon, then search for a window from the same pid, then read its
WM_CLASS, then set that on the icon. It can be done, but it will take some work, so I'm not sure if or when I get to this. In the same vein I could get a title from
TLDR: the spec supports most of it, but e.g. electron doesn't set it properly. Needs some workaround work.
I'm thinking about rewriting most of snixembed to not use the Gtk+ StatusIcon but use Xlib instead, if I ever get to that it will be easier to implement some of this. But that won't be Soon (TM).
Oh, I see now, you want to get the windows in some way to toggle them on left click. Telegram does seem to properly set the title via SNI, so I can at least set WM_NAME to what is provided through SNI and that will work in some cases. Will do that soon!
Turns out it's hard for me to test this without writing a full system tray. Does the xhints fix your issue for well-behaving (Qt) apps like Telegram?
There is StatusNotifierWatcher for GNOME as extension but have some dead ends (https://github.com/ubuntu/gnome-shell-extension-appindicator). set_name works and is probably good enough, set_title could be skipped since it not add any additional information and snixembed could be detected by that. Thanks ;)
Alright, I'll just set the name then for now, maybe the title later if I properly get that rigged up with callbacks if it changes. Thanks for testing! Leaving this open as a reminder to do the rest in the future.