14
6
Question summary: I want one of my mouse buttons to be registered as the left Windows button Super_L by X11.
In my window manager, I can move windows around by holding the "left Windows button" (Left Super) and dragging a window with the left mouse button. I want to be able to do that without touching the keyboard, so I want to map the left Super key to mouse button 11, that way I can hold mouse button 11 and click+drag windows.
The most obvious solution is using xbindkeys and xte like this (.xbindkeysrc
):
"xte 'keydown Super_L'"
b:11
"xte 'keyup Super_L'"
b:11 + release
This works like this:
- When I press down mouse button 11, Super_L is also pressed down
- When I release mouse button 11, Super_L is also released
But there's a problem: I can't move windows using Super_L + Mouse1 if I'm also holding down another mouse button, like Mouse button 11. Using the solution above, mouse button 11 is still being registered as pressed and released, and so none of the window manager operations work.
I have tried this using both Cinnamon and Awesome WM, and absolutely none of the Super_L keyboard combinations work while mouse button 10 or 11 is being held down.
A subpar hack
I'm currently working around this issue by causing the mouse 11 click to hold the Super_L button for a certain amount of time. That way I can click the mouse button, then drag stuff around for a brief period afterwards:
"xte 'keydown Super_L' 'usleep 250000' 'keyup Super_L'"
b:11
Another attempt
As suggested by totti, I tried this xbindkeys
configuration:
"xte 'mouseup 10' 'keydown Super_L'"
b:10
"xte 'keyup Super_L'"
b:10 + Release
It doesn't work. It seems the Super_L key is being held down, because as soon as I release button 10 it remains held down for ever (until I press the Super_L key again on the keyboard) but the mouse button is still being registered, because I can't click&drag windows. I don't think I'm going to be able to make this work using xbindkeys
and xte
.
1Instead of binding the mouse button to super key, do remapping. For this use xmodmap . see the arch wiki xmodmap page for a complete setup. – totti – 2015-03-12T08:19:07.587
@totti: The arch wiki xmodmap page describes how to map keys to other keys, how to swap modifier keys and how to reverse scrolling, but it doesn't mention mapping keyboard keys to mouse buttons – Hubro – 2015-03-16T01:15:56.073
@totti: With xmodmap I can map keys to other keys, and with the XKB extension for X (and xkbset) I can map mouse buttons to keyboard keys, but I'm trying to map a keyboard key to a mouse button. I still haven't found a way to do that. – Hubro – 2015-03-17T22:54:47.360
try: On mouse button 11 hold, simulate super hold + mouse button 11 release. The window manager may now detect super & mouse 1 not mouse 11. – totti – 2015-03-18T16:53:21.170
@totti: Tried, and edited question – Hubro – 2015-03-18T20:07:28.290
Does
compiz config setting manager
support on your window manager ? – totti – 2015-03-23T16:24:55.300Can you run a script on mouse click? – totti – 2015-03-23T16:27:15.767
@totti: Yes, I can – Hubro – 2015-03-23T17:13:36.653
I'm actually looking for a similar hack to rebind my Thinkpad 3 mouse buttons to trigger keyboard events. I found out the
xbindkeys
by myself as well. Still no luck so far? – zmo – 2017-01-28T00:31:31.667An alternative handy feature is the ability to move windows by moving the little rectangles that appear in the Plasma desktop pager. On another note, does the solution in this thread fit your case?
– harrymc – 2017-01-28T08:01:27.393In my above comment this answer does exactly what you want and does not suffer from xbindkeys grabbing the entire mouse. See if it fits your case.
– harrymc – 2017-02-01T19:14:26.763Thank you @harrymc your link helped a lot, and I know got a working solution! If you make an answer to give main elements, I'll give you the reward ;-) – zmo – 2017-02-01T22:49:56.720
Done as requested. – harrymc – 2017-02-02T08:41:04.643