Repository: pwr-Solaar/Solaar

Issue:
solaar still failing on Wayland
Issue #1006 has not been fixed completely:

Dec 02 07:16:21 boris-ubuntu solaar.desktop[2459]:   File "/usr/local/lib/python3.8/dist-packages/solaar/ui/diversion_rules.py", line 28, in <module>
Dec 02 07:16:21 boris-ubuntu solaar.desktop[2459]:   File "/usr/local/lib/python3.8/dist-packages/solaar/ui/window.py", line 40, in <module>
Dec 02 07:16:21 boris-ubuntu solaar.desktop[2459]:   File "/usr/local/lib/python3.8/dist-packages/solaar/ui/tray.py", line 35, in <module>
Dec 02 07:16:21 boris-ubuntu solaar.desktop[2459]:   File "/usr/local/lib/python3.8/dist-packages/solaar/ui/__init__.py", line 96, in <module>
Dec 02 07:16:21 boris-ubuntu solaar.desktop[2459]:     import solaar.ui as ui
Dec 02 07:16:21 boris-ubuntu solaar.desktop[2459]:   File "/usr/local/lib/python3.8/dist-packages/solaar/gtk.py", line 152, in main
Dec 02 07:16:21 boris-ubuntu solaar.desktop[2459]: solaar: error: Traceback (most recent call last):



Discussion:
Please provide more of the error output.    I don't see what the error is.
Syslog does not have anything else ...
Found it:

Dec 02 07:16:21 boris-ubuntu gnome-shell[2650]: Errors from xkbcomp are not fatal to the X server
Dec 02 07:16:21 boris-ubuntu gnome-shell[2650]: > Internal error:   Could not resolve keysym Invalid
Dec 02 07:16:21 boris-ubuntu gnome-shell[2650]: >                   X11 cannot support keycodes above 255.
Dec 02 07:16:21 boris-ubuntu gnome-shell[2650]: > Warning:          Unsupported maximum keycode 569, clipping.
Dec 02 07:16:21 boris-ubuntu gnome-shell[2650]: The XKEYBOARD keymap compiler (xkbcomp) reports:
Dec 02 07:16:21 boris-ubuntu solaar.desktop[2459]: Xlib.error.DisplayConnectionError: Can't connect to display ":0": b'No protocol specified\n'
Dec 02 07:16:21 boris-ubuntu solaar.desktop[2459]:     raise error.DisplayConnectionError(self.display_name, r.reason)
Dec 02 07:16:21 boris-ubuntu solaar.desktop[2459]:   File "/usr/local/lib/python3.8/dist-packages/Xlib/protocol/display.py", line 166, in __init__
Dec 02 07:16:21 boris-ubuntu solaar.desktop[2459]:     protocol_display.Display.__init__(self, *args, **keys)
Dec 02 07:16:21 boris-ubuntu solaar.desktop[2459]:   File "/usr/local/lib/python3.8/dist-packages/Xlib/display.py", line 71, in __init__
Dec 02 07:16:21 boris-ubuntu solaar.desktop[2459]:     self.display = _BaseDisplay(display)
Dec 02 07:16:21 boris-ubuntu solaar.desktop[2459]:   File "/usr/local/lib/python3.8/dist-packages/Xlib/display.py", line 89, in __init__
Dec 02 07:16:21 boris-ubuntu solaar.desktop[2459]:     disp_prog = Display()
Dec 02 07:16:21 boris-ubuntu solaar.desktop[2459]:   File "/usr/local/lib/python3.8/dist-packages/logitech_receiver/diversion.py", line 58, in <module>
Dec 02 07:16:21 boris-ubuntu solaar.desktop[2459]:     from logitech_receiver import diversion as _DIV
Dec 02 07:16:21 boris-ubuntu solaar.desktop[2459]:   File "/usr/local/lib/python3.8/dist-packages/solaar/ui/diversion_rules.py", line 28, in <module>
Dec 02 07:16:21 boris-ubuntu solaar.desktop[2459]:     from .diversion_rules import show_window as _show_diversion_window
Dec 02 07:16:21 boris-ubuntu solaar.desktop[2459]:   File "/usr/local/lib/python3.8/dist-packages/solaar/ui/window.py", line 40, in <module>
Dec 02 07:16:21 boris-ubuntu solaar.desktop[2459]:     from .window import popup as _window_popup
Dec 02 07:16:21 boris-ubuntu solaar.desktop[2459]:   File "/usr/local/lib/python3.8/dist-packages/solaar/ui/tray.py", line 35, in <module>
Dec 02 07:16:21 boris-ubuntu solaar.desktop[2459]:     from . import notify, tray, window  # isort:skip  # noqa: E402
Dec 02 07:16:21 boris-ubuntu solaar.desktop[2459]:   File "/usr/local/lib/python3.8/dist-packages/solaar/ui/__init__.py", line 96, in <module>
Dec 02 07:16:21 boris-ubuntu solaar.desktop[2459]:     import solaar.ui as ui
Dec 02 07:16:21 boris-ubuntu solaar.desktop[2459]:   File "/usr/local/lib/python3.8/dist-packages/solaar/gtk.py", line 152, in main
Dec 02 07:16:21 boris-ubuntu solaar.desktop[2459]: solaar: error: Traceback (most recent call last):

OK, I see the problem.

Resolving patch:
diff --git a/lib/logitech_receiver/diversion.py b/lib/logitech_receiver/diversion.py
--- a/lib/logitech_receiver/diversion.py
+++ b/lib/logitech_receiver/diversion.py
@@ -47,15 +47,15 @@
     from Xlib import XK as _XK
     _XK.load_keysym_group('xf86')
     XK_KEYS = vars(_XK)
+    disp_prog = Display()
     x11 = True
 except Exception:
-    _log.warn('Xlib not available - rules will not be activated')
+    _log.warn('X11 not available - rules will not be activated')
     XK_KEYS = {}
     x11 = False
 
 if x11:
     # determine name of active process
-    disp_prog = Display()
     NET_ACTIVE_WINDOW = disp_prog.intern_atom('_NET_ACTIVE_WINDOW')
     NET_WM_PID = disp_prog.intern_atom('_NET_WM_PID')
     root2 = disp_prog.screen().root
@@ -713,4 +713,5 @@ def _load_config_rule_file():
     rules = Rule([Rule(loaded_rules, source=_file_path), built_in_rules])
 
 
-_load_config_rule_file()
+if x11:
+    _load_config_rule_file()


Test patch: