7

I find lots of examples on how to set the mod key in xmonad, but how do I add a second mod key?

1

5 Answers 5

6

You can use xmodmap to add a second key to e.g. Mod1, so that pressing either would work with modMask = mod1Mask.

4

You can just or the keys together... watch:

$ ghci
> :m + XMonad
> :t (.|.)
(.|.) :: (Data.Bits.Bits a) => a -> a -> a
> :t mod1Mask
mod1Mask :: KeyMask
> :t mod2Mask
mod2Mask :: KeyMask
> :t mod1Mask .|. mod2Mask
mod1Mask .|. mod2Mask :: KeyMask

So as you can see you OR two key masks together to get the result that you desire. That's all it takes so you just use it like the last line there.

myAwesomeModMask = mod1Mask .|. mod3Mask
-- or whatever you want it to be

And that is all that there is to it.

Edit: Ah wait, you want two different keys to independently act as the Mod key. That is currently impossible I think as the code currently stands. Solution: check out the source and edit it yourself and then cabal install it again; it would be a small change.

2

Just to expand on Daniel Schoepe's answer, I do this in xmonad using the super key (the windows key) but I don't set anyting in xmonad.hs (other than setting modMask = mod4Mask). Using xmodmap I've set the left control as a second super key with the following in my .Xmodmap file:

remove Control = Control_L
keysym Control_L = Super_L
add Control = Control_L

You can also use xmodmap to swap capslock and control, set right control to be super as well, etc, but mind that the changes will only work in X, not in virtual terminals.

0

You may bind mod keys other mod1 by editing your xmonad.hs modMask value.

An example, binding to the mod4 (often 'Win') key:

import XMonad

main = xmonad defaultConfig
         { modMask = mod4Mask
         , terminal = "urxvt"
         }
2
  • This binds modMask to only the win key. I'm looking to bind it to two keys so pressing either of them works Nov 11, 2009 at 19:26
  • Sorry but I dont know how to do that either
    – Avis
    Nov 12, 2009 at 3:53
0

You can bind both your modMask choices to the same action. This may be achieved by cotcatMaping on your initial (key,action) List.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .