suurjaak / InputScope

Mouse and keyboard input heatmap visualizer, with statistics.
MIT License
87 stars 13 forks source link

InputScope under wayland? #33

Open jave opened 1 week ago

jave commented 1 week ago

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 commented 1 week ago

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

jave commented 1 week ago

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

suurjaak commented 1 week ago

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
jave commented 1 week ago
$ 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 commented 1 week ago

image

jave commented 1 week ago

nothing much seems to be working...

suurjaak commented 1 week ago

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

jave commented 1 week ago

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

jave commented 1 week ago

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 commented 1 week ago

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

suurjaak commented 1 week ago

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.