Repository: qtile/qtile

Issue:
StatusNotifier don't load anything
### The issue:

Distribution: ArchLinux
Qtile: 0.20.0

I'm having a problem with the StatusNotifier, and is that always that I open some app that have systemtray icon like zoom, dbus_next throws me this in the qtile log:
```
2022-03-11 18:05:29,769 ERROR libqtile loop.py:_handle_exception():L61 invalid object path: org.kde.StatusNotifierItem-23900-2
Traceback (most recent call last):
  File "/usr/lib/python3.10/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/lib/python3.10/site-packages/libqtile/widget/statusnotifier.py", line 478, in item_added
    success = future.result()
  File "/usr/lib/python3.10/site-packages/libqtile/widget/statusnotifier.py", line 95, in start
    introspection = await self.bus.introspect(self.service, self.path)
  File "/home/isaac/.local/lib/python3.10/site-packages/dbus_next/aio/message_bus.py", line 214, in introspect
    super().introspect(bus_name, path, reply_handler)
  File "/home/isaac/.local/lib/python3.10/site-packages/dbus_next/message_bus.py", line 204, in introspect
    Message(destination=bus_name,
  File "/home/isaac/.local/lib/python3.10/site-packages/dbus_next/message.py", line 92, in __init__
    assert_object_path_valid(self.path)
  File "/home/isaac/.local/lib/python3.10/site-packages/dbus_next/validators.py", line 153, in assert_object_path_valid
    raise InvalidObjectPathError(path)
dbus_next.errors.InvalidObjectPathError: invalid object path: org.kde.StatusNotifierItem-23900-2
```
This happened to me in X11 and Wayland

### Required:

- [X] I have searched past issues to see if this bug has already been reported.


Discussion:
Thanks. I can replicate this.

Looking at the d-bus interface, I can see the app should be showing an icon so I need to see why it's crashing the widget.

EDIT: ah, it doesn't provide the correct path to the interface. Let me see if adding a fallback works.

Resolving patch:
diff --git a/libqtile/widget/statusnotifier.py b/libqtile/widget/statusnotifier.py
--- a/libqtile/widget/statusnotifier.py
+++ b/libqtile/widget/statusnotifier.py
@@ -26,7 +26,7 @@
 from typing import Callable, List, Optional
 
 import cairocffi
-from dbus_next import InterfaceNotFoundError, InvalidBusNameError
+from dbus_next import InterfaceNotFoundError, InvalidBusNameError, InvalidObjectPathError
 from dbus_next.aio import MessageBus
 from dbus_next.constants import PropertyAccess
 from dbus_next.errors import DBusError
@@ -94,7 +94,24 @@ def __eq__(self, other):
 
     async def start(self):
         # Create a proxy object connecting for the item.
-        introspection = await self.bus.introspect(self.service, self.path)
+        # Some apps provide the incorrect path to the StatusNotifier object
+        # We can try falling back to the default if that fails.
+        # See: https://github.com/qtile/qtile/issues/3418
+        # Note: this loop will run a maximum of two times and returns False
+        # if the no object is available.
+        found_path = False
+
+        while not found_path:
+            try:
+                introspection = await self.bus.introspect(self.service, self.path)
+                found_path = True
+            except InvalidObjectPathError:
+                logger.info(f"Cannot find {self.path} path on {self.service}.")
+                if self.path == STATUSNOTIFIER_PATH:
+                    return False
+
+                # Try the default ('/StatusNotifierItem')
+                self.path = STATUSNOTIFIER_PATH
 
         try:
             obj = self.bus.get_proxy_object(self.service, self.path, introspection)


Test patch: