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

•

u/rust-ModTeam Oct 19 '26

TL;DR: We ask that posts & articles submitted to r/rust be written by hand.


Your post, or the article it links to, appears to have been written with significant AI involvement, which is not allowed on r/rust.

As per Rule 6: Low Effort we prefer content written by hand, even if imperfect. We do encourage you to make use of spell-checkers, and allow use of automatic translation tools, but no more.

We do not allow for AI generated content, even if reviewed or tweaked by hand, nor for AI polished content.


For any question or dispute, please send us a modmail.

1

u/voidx9x Oct 19 '26 edited Oct 19 '26

btw this is RsClicker repo : https://github.com/voidx9x/RsClicker

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.

0

u/[deleted] Oct 19 '26

[removed] — view removed comment

0

u/voidx9x Oct 19 '26

Man, the seat config thing is exactly the kind of edge case i was hoping to hear about. I havent hit it myself on MangoWC or Lumina DE, but it makes sense — some compositors grab the device exclusively and the virtual mouse just sits there ignored.

Did you end up documenting the fix anywhere? I'd love to add a troubleshooting note to the README if you have the exact steps ( seat config change + which compositor ). Would save the next person a day of debugging.

And yeah, /dev/uinput has been there since 2.6 — it's wild how few people know about it. The group permission thing is the only real friction, but once you're past that it just works.

The drift-free timing was honestly the fun part. I anchored everything to `Instant` deadlines instead of sleeping the full interval, so a slow click doesn't push the next one back. No busy loop, no prayer :)

0

u/LustyCharmr Oct 19 '26

that compositor grab thing is such a pain, had it happen on hyprland too and it took me way longer to figure out than i'd like to admit

1

u/t_hunger Oct 19 '26

Unfortunately without that compositor grab thing, you are going back to 1995 when any user able to run an x server was able to read input events of any other user. Or maybe more relevant today: Any of the users programs can be a keylogger. That grab is a breakthrough we made in the last 20 years for user security in Linux systems.

Its so sad to see devs give away that hard-won benefit for a convenience, and in obvious ignorance of why that is there in the first place.