How can I set my Caps Lock key to toggle Fullscreen mode in Xmonad?

I'm using xmonad with the following layouts:

globalLayout = avoidStruts (tiled ||| Mirror tiled ||| Full ||| threeColMid ||| combine) ||| Full

and I have set my mod + space key to switch between the layouts by:

, ((modm, xK_space ), sendMessage NextLayout)

Now I want to bind my CapsLock key to toggle the Full mode. How can I do that? (Maybe with setLayout?)


Solution 1:

see XMonad.Layout.MultiToggle

You need two imports:

import XMonad.Layout.MultiToggle
import XMonad.Layout.MultiToggle.Instances

key binding:

((modm, xK_Caps_Lock), sendMessage $ Toggle FULL)

layout:

layout
  = smartBorders
  $ mkToggle (NOBORDERS ?? FULL ?? EOT)
  $ tiled ||| Mirror tiled ||| etc...

Enjoy.