pynput
pynput copied to clipboard
Wayland backend
@TMiguelT made a good summary in https://github.com/moses-palmer/pynput/issues/184#issuecomment-534546626 about what it would take to create a wayland backend.
Is anyone working on this?
Yes, the uinput backend is implemented: https://github.com/moses-palmer/pynput/blob/master/CHANGES.rst#v170-2020-08-30---a-new-backend-and-many-new-features-and-bug-fixes.
I believe it should automatically activate when you're on Linux, aren't on X11 and possibly you will have to run the script with sudo. Otherwise, I think the backend is called uinput if you want to force it to enable.
I know about uinput, but I was referring to your comments about becoming a Wayland client.
Oh right, no. As I explain in the comment you linked to, that approach wouldn't consistently work. Rather we will have to wait for a virtual device proposal to get passed and implemented in Wayland. I'm not sure where any of that stuff is up to, however.
Oh right, I thought there might have been progress (on the Wayland side) since your comment was from a year ago.
Oh it seems there has been some progress. So on the Wayland protocol side there are a few proposals but neither have been accepted:
- https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/11
- https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/12
What's interesting, though, is that both of these protocols are apparently already implemented in sway and other wlroots-based compositors. I think this code snippet demonstrates a CLI for manipulating the pointer (like xdotool) for compositors that support the protocol: https://github.com/swaywm/wlroots/blob/master/examples/virtual-pointer.c. I suppose there is some argument against building on a protocol that isn't yet officially part of Wayland, but still it looks like the best option at the moment.
That sounds interesting.
Unfortunately, I'm not advanced enough to contribute support. If you add this or mouse support for uinput (#332), I'd be happy to test though.
The long term solution for Wayland support would be to implement these protocols, but I am reluctant to do that before they have been finalised and thoroughly documented.
Agreed. But in theory if someone urgently wanted this feature now, I think they could implement C bindings for these unstable protocols, and you could get Python automating the mouse + keyboard on certain Wayland environments (not stock Gnome, though, which I assume is the most common DE on Linux atm).
Hi there! Now that Ubuntu 21 is out, and using Wayland by default, the library seems to be bugging a bit :confused:
But it does work... sometimes?
Yes, it still works with applications running under XWayland, but Wayland being default on Ubuntu makes an implementation for the protocols listed above even more urgent.
A global keybinds portal exists now, as of xdg-desktop-portal 1.16.
As for emulating input, it'll either need root or an external library such as libei (which is currently being worked on to go through xdg-desktop-portal as well).
You could also possibly manage this via the RemoteDesktop portal.
As for emulating input, it'll either need root or an external library such as
libei(which is currently being worked on to go through xdg-desktop-portal as well).
Looks like libei 1.0 was released in June, with 1.1.0 already being out by now. Here is the release announcement:
https://lists.freedesktop.org/archives/wayland-devel/2023-June/042731.html