Binding mouse buttons

HarboursideThis was going to be the squib of the day for May 8th (yes, I have it all planned out) but I thought it was so interesting and potentially useful that I wrote a patch already.

Metacity lets you bind keystrokes to all sorts of things, but it doesn’t let you bind all those extra buttons on your mouse to anything at all. I don’t have a particularly flashy mouse, and it has the usual left and right buttons, plus a scroll wheel (i.e. up and down buttons) which doubles as a middle button, and can be pushed left and right as well, plus two shoulder buttons and a two-way zoom control.  That’s eleven buttons.  GNOME bug 374601 asks for them to be bindable in the same way keystrokes are bindable.

The patch added this evening lets you bind these as Buttonn, e.g. Button5, possibly including some modifiers such as <Alt>.  Which button Button5 is is unfortunately down to you to find out; you can discover the answer using

xev|grep -A2 ButtonPress

and clicking in the resulting window with each button in turn.

Feedback on the patch is very welcome; I’m not certain the use of a flag bit rather than a separate flag was wise, and I don’t know whether it was worthwhile to forbid the user to bind the left, middle, and right buttons and the scrollwheel on the grounds that they’re commonly used by applications.  I mean, perhaps you want <Alt>Middle to do something and you don’t really care that it’s taking a possible button press away from your apps.

Try the patch out and see whether it works for you.  I’m trying it myself at the moment with the various extra buttons bound to switch_to_workspace_n and it’s proving its worth already.

Photo © Thristian, cc-by-sa.

Published by

Thomas Thurman

Mostly themes, triaging, and patch review.

5 thoughts on “Binding mouse buttons”

  1. (sorry for hijacking this post) is it a metacity bug that when I disconnect one of my monitors and do xrandr –auto, not all windows are moved back to the remaining one?

  2. This is genuinely cool, and the only reason I look somewhat lustfully at compiz on occaision. However, speaking as someone who only has three buttons I beg you to reconsider the ban on the left/right/middle click.
    The same argument can be made for normal modifier keys even more so than for mouse buttons. If overriding ctrl+left arrow is possible, there’s no reason you shouldn’t be able to use mouse buttons.
    The only disclaimer to this is that they should be exempt from the “Naked Modifiers” rule for obvious reasons.

  3. I recently came across your blog and have been reading along. I thought I would leave my first comment. I don’t know what to say except that I have enjoyed reading. Nice blog. I will keep visiting this blog very often.

    Alanna

Leave a Reply

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

Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported.