Code Monkey home page Code Monkey logo

Comments (8)

RedBearAK avatar RedBearAK commented on June 27, 2024 1

This seems to be some kind of internal issue with Xlib version 0.32, so pinning the version to 0.31 should avoid it until the fix is in place. One fix apparently exists, but has not been merged, for some reason.

python-xlib/python-xlib#241
python-xlib/python-xlib#242
python-xlib/python-xlib#259

To install a specific version of the package with pip:

pip install python-xlib==0.31

It may not be quite that straightforward if you're using pipx to install keyszer and relying on the system python-xlib package, which is probably 0.32 or 0.33 by now. Using a full Python virtual environment is probably the best way to handle these things.

I haven't experienced anything like this with my own project that is using a modified fork of keyszer with Wayland support. I don't run keyszer as root, or do much connecting/disconnecting of devices, but I've been testing my project in dozens of Linux distros in Boxes virtual machines without seeing this issue. Though mostly in Wayland to make sure the Wayland support is working.

Looks like wrapping this line in xorg.py in a try/except could at least stop it from crashing keyszer, but I'm not sure what the side effects would be.

  File "/root/.local/pipx/venvs/keyszer/lib/python3.11/site-packages/keyszer/xorg.py", line 36, in get_xorg_context
    wm_name = window.get_full_text_property(_display.get_atom("_NET_WM_NAME"))
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

from keyszer.

fecet avatar fecet commented on June 27, 2024 1

I haven't experienced anything like this with my own project that is using a modified fork of keyszer with Wayland support.

Did you mean https://github.com/RedBearAK/toshy? It looks promising, does it support https://github.com/hyprwm/Hyprland?

from keyszer.

fecet avatar fecet commented on June 27, 2024

Here is the log

keyszer v0.6.92
(--) ROOT: Yes, I am.  --very-bad-idea acknowledged.
(--) Autodetecting all keyboards (--device not specified)
(+K) Grabbing 'Logitech USB Receiver' (/dev/input/event15)
(+K) Grabbing 'HTKB HTKB HHKB-BLE' (/dev/input/event19)
(+K) Grabbing 'HTKB HTKB HHKB-BLE Keyboard' (/dev/input/event22)
(--) Ready to process input.
ls
llsException in callback receive_input(InputDevice('...nput/event19')) at /root/.local/pipx/venvs/keyszer/lib/python3.11/site-packages/keyszer/input.py:102
handle: <Handle receive_input(InputDevice('...nput/event19')) at /root/.local/pipx/venvs/keyszer/lib/python3.11/site-packages/keyszer/input.py:102>
Traceback (most recent call last):
  File "/usr/lib/python3.11/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/root/.local/pipx/venvs/keyszer/lib/python3.11/site-packages/keyszer/input.py", line 117, in receive_input
    on_event(event, device)
  File "/root/.local/pipx/venvs/keyszer/lib/python3.11/site-packages/keyszer/transform.py", line 347, in on_event
    if context.x_error:
       ^^^^^^^^^^^^^^^
  File "/root/.local/pipx/venvs/keyszer/lib/python3.11/site-packages/keyszer/lib/key_context.py", line 27, in x_error
    self._query_window_context()
  File "/root/.local/pipx/venvs/keyszer/lib/python3.11/site-packages/keyszer/lib/key_context.py", line 13, in _query_window_context
    self._X_ctx = get_xorg_context()
                  ^^^^^^^^^^^^^^^^^^
  File "/root/.local/pipx/venvs/keyszer/lib/python3.11/site-packages/keyszer/xorg.py", line 36, in get_xorg_context
    wm_name = window.get_full_text_property(_display.get_atom("_NET_WM_NAME"))
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.local/pipx/venvs/keyszer/lib/python3.11/site-packages/Xlib/xobject/drawable.py", line 486, in get_full_text_property
    prop = self.get_full_property(property, property_type,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.local/pipx/venvs/keyszer/lib/python3.11/site-packages/Xlib/xobject/drawable.py", line 476, in get_full_property
    prop = self.get_property(property, property_type, sizehint,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.local/pipx/venvs/keyszer/lib/python3.11/site-packages/Xlib/xobject/drawable.py", line 455, in get_property
    r = request.GetProperty(display = self.display,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.local/pipx/venvs/keyszer/lib/python3.11/site-packages/Xlib/protocol/rq.py", line 1368, in __init__
    self.reply()
  File "/root/.local/pipx/venvs/keyszer/lib/python3.11/site-packages/Xlib/protocol/rq.py", line 1380, in reply
    self._display.send_and_recv(request = self._serial)
  File "/root/.local/pipx/venvs/keyszer/lib/python3.11/site-packages/Xlib/protocol/display.py", line 612, in send_and_recv
    gotreq = self.parse_response(request)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.local/pipx/venvs/keyszer/lib/python3.11/site-packages/Xlib/protocol/display.py", line 719, in parse_response
    gotreq = self.parse_error_response(request) or gotreq
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.local/pipx/venvs/keyszer/lib/python3.11/site-packages/Xlib/protocol/display.py", line 745, in parse_error_response

from keyszer.

joshgoebel avatar joshgoebel commented on June 27, 2024

Is it the full log? I don't see it mention BadRRModeError at the bottom.

from keyszer.

fecet avatar fecet commented on June 27, 2024

Oops, will upload full log next time crashed.

But I think this should be

keyszer v0.6.92
(--) ROOT: Yes, I am.  --very-bad-idea acknowledged.
(--) Autodetecting all keyboards (--device not specified)
(+K) Grabbing 'Logitech USB Receiver' (/dev/input/event15)
(+K) Grabbing 'HTKB HTKB HHKB-BLE' (/dev/input/event19)
(+K) Grabbing 'HTKB HTKB HHKB-BLE Keyboard' (/dev/input/event22)
(--) Ready to process input.
ls
llsException in callback receive_input(InputDevice('...nput/event19')) at /root/.local/pipx/venvs/keyszer/lib/python3.11/site-packages/keyszer/input.py:102
handle: <Handle receive_input(InputDevice('...nput/event19')) at /root/.local/pipx/venvs/keyszer/lib/python3.11/site-packages/keyszer/input.py:102>
Traceback (most recent call last):
  File "/usr/lib/python3.11/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/root/.local/pipx/venvs/keyszer/lib/python3.11/site-packages/keyszer/input.py", line 117, in receive_input
    on_event(event, device)
  File "/root/.local/pipx/venvs/keyszer/lib/python3.11/site-packages/keyszer/transform.py", line 347, in on_event
    if context.x_error:
       ^^^^^^^^^^^^^^^
  File "/root/.local/pipx/venvs/keyszer/lib/python3.11/site-packages/keyszer/lib/key_context.py", line 27, in x_error
    self._query_window_context()
  File "/root/.local/pipx/venvs/keyszer/lib/python3.11/site-packages/keyszer/lib/key_context.py", line 13, in _query_window_context
    self._X_ctx = get_xorg_context()
                  ^^^^^^^^^^^^^^^^^^
  File "/root/.local/pipx/venvs/keyszer/lib/python3.11/site-packages/keyszer/xorg.py", line 36, in get_xorg_context
    wm_name = window.get_full_text_property(_display.get_atom("_NET_WM_NAME"))
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.local/pipx/venvs/keyszer/lib/python3.11/site-packages/Xlib/xobject/drawable.py", line 486, in get_full_text_property
    prop = self.get_full_property(property, property_type,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.local/pipx/venvs/keyszer/lib/python3.11/site-packages/Xlib/xobject/drawable.py", line 476, in get_full_property
    prop = self.get_property(property, property_type, sizehint,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.local/pipx/venvs/keyszer/lib/python3.11/site-packages/Xlib/xobject/drawable.py", line 455, in get_property
    r = request.GetProperty(display = self.display,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.local/pipx/venvs/keyszer/lib/python3.11/site-packages/Xlib/protocol/rq.py", line 1368, in __init__
    self.reply()
  File "/root/.local/pipx/venvs/keyszer/lib/python3.11/site-packages/Xlib/protocol/rq.py", line 1380, in reply
    self._display.send_and_recv(request = self._serial)
  File "/root/.local/pipx/venvs/keyszer/lib/python3.11/site-packages/Xlib/protocol/display.py", line 612, in send_and_recv
    gotreq = self.parse_response(request)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.local/pipx/venvs/keyszer/lib/python3.11/site-packages/Xlib/protocol/display.py", line 719, in parse_response
    gotreq = self.parse_error_response(request) or gotreq
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.local/pipx/venvs/keyszer/lib/python3.11/site-packages/Xlib/protocol/display.py", line 745, in parse_error_response
    req = self.get_waiting_request(e.sequence_number)
AttributeError: 'BadRRModeError' object has no attribute 'sequence_number'

by merging #137 (comment)

from keyszer.

RedBearAK avatar RedBearAK commented on June 27, 2024

@fecet

That's the one. Toshy installs a development branch of keyszer with an adaptable window context module, capable of dealing with more environments than just X11/Xorg.

That branch of keyszer does not have Hyprland support yet. But the project that I've been drawing from has Wayland support for GNOME, KDE, sway, and Hyprland environments. So you may want to take a look at that.

https://github.com/k0kubun/xremap

In theory the sway and Hyprland support could also be added to the same branch of keyszer that I'm using, but I'd have to take a close look at how they're doing it in xremap, and whether those environments actually provide the window name info Toshy needs.

from keyszer.

fecet avatar fecet commented on June 27, 2024

Thanks for your link, I tried xremap and it works both at x11 and hyprland (should build seperately though). However I still encouther rust-windowing/winit#2898 (comment), did you know what's the magic behind keyszer?

from keyszer.

RedBearAK avatar RedBearAK commented on June 27, 2024

@fecet

I don't know keyszer deeply to know why you're not seeing a similar bug.

I'm trying to figure out if I can get what I need from Hyprland, but I don't have a way to run it right now. Would you mind starting a new issue in the Toshy repo and providing some sample output from commands like hyprctl clients -j and hyprctrl activewindow -j? You can title it something like (enh) Hyprland support.

https://github.com/RedBearAK/toshy/issues

from keyszer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.