InputScope icon indicating copy to clipboard operation
InputScope copied to clipboard

InputScope under wayland?

Open jave opened this issue 1 year ago • 11 comments

I'm switching from i3wm to sway, and InputScope doesnt seem to work, no keyboard events seem to be monitored. Is InputScope verified to work under wayland (sway in my case)?

jave avatar Sep 21 '24 21:09 jave

On further reading, it seems keyloggers arent really straightforward on wayland.

jave avatar Sep 21 '24 22:09 jave

this seems to list keycodes logs under wayland: sudo libinput debug-events --show-keycodes maybe this could be interfaced to inputscope somehow.

jave avatar Sep 21 '24 22:09 jave

Haven't experimented with Wayland myself, and at the moment I am not able to.

Looking at the documentation for pynput, the library that InputScope uses for events, Wayland support is iffy indeed (https://pynput.readthedocs.io/en/latest/limitations.html#linux and https://pynput.readthedocs.io/en/latest/index.html#forcing-a-specific-backend).

Can you try running the program as root? For Wayland, it needs the following environment:

export PYNPUT_BACKEND_KEYBOARD=uinput

suurjaak avatar Sep 22 '24 12:09 suurjaak

$ xhost +
access control disabled, clients can connect from any host
01:31:47-joakim@framework:~/roles/Tools/InputScope
$ sudo DISPLAY=:0 PYTHONPATH=/home/joakim/.local/lib/python3.12/site-packages PYNPUT_BACKEND_KEYBOARD=uinput PYNPUT_BACKEND_MOUSE=dummy  ~/.local/bin/inputscope

** (inputscope:722274): WARNING **: 01:31:50.749: AT-SPI: Could not obtain desktop path or name


** (inputscope:722274): WARNING **: 01:31:50.750: atk-bridge: GetRegisteredEvents returned message with unknown signature

** (inputscope:722274): WARNING **: 01:31:50.750: atk-bridge: get_device_events_reply: unknown signature
Exception in thread Thread-4:
Traceback (most recent call last):
  File "/usr/lib64/python3.12/threading.py", line 1075, in _bootstrap_inner
    self.run()
  File "/home/joakim/.local/lib/python3.12/site-packages/pynput/_util/__init__.py", line 211, in run
    self._run()
  File "/home/joakim/.local/lib/python3.12/site-packages/pynput/_util/__init__.py", line 260, in _run
    raise NotImplementedError()
NotImplementedError

jave avatar Sep 23 '24 23:09 jave

image

jave avatar Sep 23 '24 23:09 jave

nothing much seems to be working...

jave avatar Sep 23 '24 23:09 jave

What happens if you try without the DISPLAY=:0 in front of command?

suurjaak avatar Sep 24 '24 10:09 suurjaak

then i get some exception and it dies. let me try so you can see

jave avatar Sep 24 '24 10:09 jave

sudo DISPLAY= PYTHONPATH=/home/joakim/.local/lib/python3.12/site-packages PYNPUT_BACKEND_KEYBOARD=uinput PYNPUT_BACKEND_MOUSE=dummy ~/.local/bin/inputscope Unable to access the X Display, is $DISPLAY set properly?

jave avatar Sep 24 '24 11:09 jave

btw for my use-case (figuring out which keys I use so I can build a zsa voyager keyboard layout) I dont need mouse, so thats why I use PYNPUT_BACKEND_MOUSE=dummy

jave avatar Sep 24 '24 11:09 jave

I will try to get native Linux installed somewhere at some point, and look into this further.

Unfortunately this may take a while. Leaving this issue open until then.

suurjaak avatar Sep 26 '24 17:09 suurjaak