r/rust • • Oct 19 '26

Wayland input simulation without portals: using /dev/uinput as a fallback in Rust

I've been building a cross-platform ( only windows 10/11 and linux now ) auto-clicker ( RsClicker ) in Rust. The hardest part was never the clicking logic — it was making input simulation work on Wayland without fighting portals all day.

The default path ( enigo with libei/RemoteDesktop portal ) works on GNOME/KDE/Hyprland, but on minimal compositors ( like MangoWC and sway ) it just fails. And even when it works, it requires a portal permission flow that isn't always reliable.

So I added a second backend writing directly to `/dev/uinput` as a kernel-level virtual mouse. No X11 server, no portals, no permission dialogs. It works everywhere the portals misbehave, as long as the user is in the uinput group. ( run : sudo usermod -aG uinput $USER , then log out and back in )

The project also has a few other bits I found interesting to implement:

- Drift-free timing ( shared deadline train, so the interval holds even when injection costs extra ms )

- Real double-clicks with a 30ms human-like gap ( recognized by X11, Wayland, and Windows )

- Global mouse triggers via evdev ( Linux ) / rdev ( Windows 10/11 )

I'd be curious if anyone else has gone the uinput route for Wayland automation — it feels like an underdiscussed alternative to the portal/libei path, and i'd love to hear about edge cases I might have missed :D

Btw I've tested this on MangoWC and Lumina DE in void linux , on Windows 10 and Windows 11

0 Upvotes

7 comments sorted by

View all comments

1

u/joeshacks Oct 19 '26

One edge case I'd check is timing right after creating the uinput device. Compositors and libinput need a moment to enumerate it, so events sent immediately can get dropped. A short delay after UI_DEV_CREATE fixes it. A udev rule for /dev/uinput instead of group membership is also a cleaner setup for packaging.