[HowTo] Use Mouse Gestures together with(out) Xdotool (Custom Shortcuts)

Since I could not figure out how to do it without I installed

sudo pacman -Syu xdotool

In System Settings go to Workspace > Shortcuts > Custom Shortcuts

Right click where my arrow is and select New Group and name that category Mouse Gestures (just to overview all more easily).

Also go to Settings below and tick “Gestures” and “Start the Input Actions daemon on login”.
Middle Mouse button I find perfectly suitable. Usually it does nothing by default when you HOLD it down.
Now we will make gestures that you “draw” with your mouse holding down the middle mouse key.

Now you can create your own gestures. See my selection.
To make one, right click, select: New > Mouse Gesture Action > Command/URL

Name it, I named it to what they do, e. g. “F2” or “Ctrl+Z” in my list above.
(If you want to comment it, feel free in the Comment tab)
In this example, we’ll make a gesture for CTRL+X
Go to tab: Trigger and hit Edit below.


You’ll see a dialogue window pop up. Inside this smaller window, draw your gesture using the left mouse button.
Since I want to make a gesture for CTRL+X, I drew an X like I would write X.
You’ll see the result in green and blue. Hit Apply.

Go to tab Action and here put
xdotool key ctrl+x

Hit Apply again.


Also for the F-Keys this is very handy. See my F2:

Action tabs gets:
xdotool key F2

Notes:
1.) Ctrl+V (Of course I drew a V as gesture) works way more handy in all situations than the default click-middle-mouse-key action in KDE, since it only pastes what you cut or copied right before, and not as well what you deleted after marking it.
2.) For Ctrl+A which is select all in the active window, I drew a circle and no A.
This seems like a natural gesture for grabbing it all.
3.) To open K-Runner (which uses the default key combo, so: xdotool key alt+space) :soon:
I simply drew a horizontal line from left to right since this is about what K-Runner looks when it opens.

1 Like

FYI

This tool only works on X11 without root permission.
I do not think it works on Wayland.
But there is ydotool which runs on root to read Kernel device input. It is independent of X11 and Wayland, but it requires root permission. That is a bad idea.

2 Likes

This is the wrong way to install packages.

sudo pacman -Syu xdotool

1 Like

Gestures only work with X11 - one reason I feel increasing panic as Wayland looms ever larger. Losing mouse gestures isn’t even marked on their radar, nobody cares about them any more - even though once you’ve had a taste of them, they’re impossible to give up.

Especially for stuff like tabs - open/close/reopen or windows - max/min/tile/vertical and horizontal max or whatever.

I don’t think you need xdotool to enable KDE gestures. However, before using KDE I used Easystroke - which has the benefit of drawing a trail.

I actually prefer the Right mouse button, as I got used to it in the early days of using Opera browser.

I don’t actually use a gesture to copy or cut text - but for pasting, I draw a ‘V’ to bring up the clipboard list next to the cursor to select what to paste.

With Easystroke you can also do instant gestures, so holding down the right mouse button and scrolling the mousewheel is the same as Ctrl_Tab (scroll tabs) or Shift_Ctrl_Tab.

Also, the ‘fwd/back’ side mouse buttons (8 and 9) can be instant - so that my ‘fwd’ button grabs a window to move, and my ‘back’ button resizes a window.

FYI again

As far as I know, KDE Wayland already supports native drawing with the mouse on the desktop screen.
For example:

  1. Open System SettingsDesktop Effects → Enable “Mouse Mark
  2. Press and hold Window / Meta + Shift and move your mouse to draw a red line on the desktop screen.
  3. Press Window / Meta + Shift + F11 to delete this drawing.

That works for me when using full AMD system, not for Nvidia.

But it lacks a feature to add custom shortcuts for running commands or programs.
I think a new alternative of this will most likely come in the future. Time is endless, some developers will implement this. :point_down:

There is a chance to implement it. See [Available until the end of 2024] Mouse gestures support on Plasma 6 Wayland - Sponsored Work - KDE Discuss if you are willing to donate!

Source: 436627 – Mouse gestures don't work in Wayland

1 Like

So then I can enjoy them until March I think :smiley:
Plasma 6 Wayland’s nicest feature will be supporting per-screen accent-color from wallpaper.

Wow, excellent - I hope it pulls through.

I tried to find the built-in thing but could find nowhere to place key combos with gestures.

Thanks for the tip, however I found that the Onboard keyboard (again, only working on X11) is producing 2 capital letters on right click. Must be xdotool that works that way.

The ‘built in thing’.

KDE, hit the menu and type/launch Custom.

In the ‘Custom Shortcuts’ column, right click and select ‘New Mouse Gesture Action’ and 'send keyboard input`.

In the next pane, under Comment, you can type ‘krunner’. Or you could jus type Alt+Space and copy/paste that into the Action window where you would normally type the keyboard input.

Then under ‘Trigger’ you go down and click ‘Edit’ and use the left mouse button to draw your shape.

Now, by pressing the middle mouse button I can call up krunner with that gesture.

With the same method, you can make gestures to manipulate, max/min windows, open new tabs, close tabs, whatever you can thunk up a shortcut (and shortcuts don’t need to be practical).

You can probably go with commands and use qdbus commands too…

Desktop Grid: qdbus org.kde.kglobalaccel /component/kwin org.kde.kglobalaccel.Component.invokeShortcut "ShowDesktopGrid";

The sky’s the limit, 'cos there’s no limit to the sky.

1 Like

I’ve heard that vague claim before; and even from John Lennon, albeit not in so many words. You might be too young to remember:

AT PAN AM THE SKY IS NO LONGER THE LIMIT

– Quote from the movie 2001: A Space Odyssey (1968)

1 Like

Thank you I’m recreating them without Xdotool. However with middle click, since right click spams me 2 capital letters on Onboard here still.

This looks promising…

I am a little excited here. Though I’m sure they’ll probably look at ydotool :wink: not xdotool.

1 Like