aw-watcher-afk icon indicating copy to clipboard operation
aw-watcher-afk copied to clipboard

Add Wayland support by providing evdev and libinput backends

Open Game4Move78 opened this issue 9 months ago • 2 comments

This PR introduces Wayland support by adding evdev and libinput backends as alternatives to pynput, which only supports X11 and XWayland (docs). These alternatives should provide Wayland support if run as root or with the appropriate group permissions (input group).

Changes:

  • Added evdev backend: Bypassing the compositor to handle input events generated in the kernel.
  • Added libinput backend: This wrapper is no longer maintained.

Related to issue ActivityWatch/aw-watcher-input#25.


[!IMPORTANT] Add Wayland support with evdev and libinput backends, updating build and configuration files for optional evdev support.

  • Behavior:
    • Adds Wayland support with evdev and libinput backends in listeners_evdev.py and listeners_libinput.py.
    • evdev backend is functional and tested; libinput backend is based on an unmaintained wrapper.
    • listeners.py updated to select backend based on USE_EVDEV and USE_LIBINPUT environment variables.
  • Build System:
    • Makefile updated to include POETRY_EXTRAS for evdev support.
    • pyproject.toml updated with optional evdev dependency and extras configuration.
  • Misc:
    • Introduces evdev_devices.py for device detection.
    • Adds listeners_pynput.py to separate pynput backend logic.

This description was created by Ellipsis for 47a5f10ca7229b970677201c84a3c060af66678f. It will automatically update as commits are pushed.

Game4Move78 avatar Feb 06 '25 15:02 Game4Move78

Why use this method of getting idle status, instead of using the staging Wayland protocol ext-idle-notify, which popular and proven Wayland watchers like awatcher and aw-watcher-window-wayland use?

johan-bjareholt avatar Feb 08 '25 13:02 johan-bjareholt

@johan-bjareholt You are right. However since aw-watcher-input uses the input event listeners found in this module to track keystrokes and mouse movements, aw-watcher-input will be supported on Wayland if this is merged. Currently there is no method for supporting aw-watcher-input on Wayland.

I am not sure why input events are currently tracked here in aw-watcher-afk rather than aw-watcher-input and the idle watcher for ActivityWatch on Linux currently uses input tracking rather than display protocols for tracking idle. As a result this PR will also cause the current implementation of aw-watcher-afk to support Wayland, even if it is only really needed to support aw-watcher-input. It's good to have implementations with Wayland support for both aw-watcher-input and aw-watcher-afk in the activitywatch repo, even if there are better solutions for aw-watcher-afk in other repos. If they are merged in future (awatcher is very good!) then this (and the existing pynput backend ) can be moved to aw-watcher-input.

Game4Move78 avatar Feb 08 '25 15:02 Game4Move78