I would like to be able to move to the previous and next workspaces using the buttons 6 and 7 (the rocker buttons either side of the wheel) on my mouse. I'm guessing it has something to do with additionalMouseBindings
, and if that followed the same pattern as additionalKeys
I'd be golden. Alas, it is not, and I don't fully understand how to define a new binding. The naive:
`additionalMouseBindings`
[ -- get the middle button to switch views
((0, button6), spawn "xdotool key super+Down")
, ((0, button7), spawn "xdotool key super+Up")
]
isn't working, for reasons that will be obvious to somebody who knows Haskell and xmonad.
TIA for any suggestions.
By "doesn't work" I suppose you mean it doesn't compile.
After @chi comment, I checked the buttons : button6 and 7 are not defined, so that is a first problem. But according to this post the extra buttons work if you just give their number.
It looks like you are using the
additionalMouseBindings
function from the XMonad.Util.EZConfig module. Its type is :You are surrounding it in backticks which turns it into an operator. You aren't showing the first operand here, of type
XConfig a
, so you could have a first error here. You should have something of the form :That expression is equal to your new XConfig.
You can see that the list of bindings for the mouse buttons is not the same type as for the keys. The elements of the list are of type
((ButtonMask, Button), Window -> X ())
: buttons are associated to a function that takes aWindow
and returnsX()
(whereas keys are associated to expressions of typeX()
). XMonad will call the function you specify here with the clicked window as argument. You don't care about the window in your case.spawn "xdotool key super+Down"
is of typeX ()
, you can turn that into a function that takes aWindow
(or anything) by making a lambda function :Or you can use
const
to get a constant function that always returnspawn "xdotool key super+Down"
:Finally, it seems really overkill to call
xdotool
to switch workspaces. Perhaps you are already using some of the functions of the module here in your key bindings ? You can use them in your mouse bindings too.nextWS
andprevWS
are of typeX()
, so you need make constant functions with them, like above.