How to center the mouse between monitors in Wayland

Questo articolo è stato scritto oltre 1 years, il contenuto potrebbe essere datato.

In the https://pagedout.institute/ Issue #6 there is a new article by me about an old project https://github.com/mte90/pydal.

Basically Pydal is a way to script a button press in a footswitch keyboard that I have since various years.
I use it with a script for X11 and `xdotool` to move based on the first or third pedal to move the mouse on that monitor (I have 3 monitor).

It worked for years but now Wayland on KDE (and Debian Sid) is the default graphic server and this solution doesn’t work anymore.

After trying tons of tools and solution for Waykand I didn’t found something to achieve the same.
With the help of ChatGPT and MistralAI I was able to develop a C++ tool that creates a virtual UIinput mouse that let’s to put the mouse in a specific coordinate.

I tried initially using the wayland spec but they have a relative pointer API, that as for the name is not absolute and doens’t work rightly with multiple monitors.

This tool is not the best as have a timer to create the device and move the mouse  and not position right in the center because it is not easy to calculate the position if you don’t have an API that helps you on the system side.
I opened also a discussion to KDE https://discuss.kde.org/t/move-mouse-to-screen/28971 to implement such a feature in KDE natively but we will see.
I want to say that after this experience I saw the various issues that Wayland has, like in KDE is not possible to identify (for the window rules) the monitor.

https://github.com/Mte90/wcentermouse

In my opinion wayland is cool but it wasn’t feature parity yet with X11, but maybe in the future the things will change.

Liked it? Take a second to support Mte90 on Patreon!
Become a patron at Patreon!

Leave a Reply

Your email address will not be published. Required fields are marked *