Open mitkof6 opened 1 year ago
Thank you for your very detailed report!
Unfortunately I have no further insights to provide; this is far beyond my use cases. Have you tried using the uinput backend instead? This can be activated by setting the environment variable PYNPUT_BACKEND_KEYBOARD=uinput
, and does not require a running X server. It does, however, require running as root
.
Description
I have a use case where I want to use pynput in a headless Linux system (e.g., without a monitor or desktop manager). I was able to start a dummy xorg server and use pynput. However, the key listener is not reactive (big delay) to normal keystrokes (e.g., the callbacks are not called when I press a normal key [k, a, b, etc.]). Paradoxically, the key listener is very reactive (no delay) when a modifier key is pressed (ctr, shift, etc.). I am wondering why this happens, and if there is a way to make this work properly for the normal keys. See the example code below to reproduce this behavior.
The key listener is reactive if I ssh into the device and run the main.py script provided below as an example or if I start the desktop manager.
Thanks for any suggestions!
Platform and pynput version
Arch Linux or Ubuntu (on raspberry pi), pynput=1.7.6
To Reproduce
sudo X :6 -config xorg_headless.conf
)export DISPLAY=:6
python3 main.py
_xorgheadless.conf
main.py