[xmonad] Layout switching (rather than cycling)

Don Stewart dons at galois.com
Fri Mar 28 16:44:56 EDT 2008


byorgey:
>    On Fri, Mar 28, 2008 at 2:45 PM, Anze Slosar <[1]anze at berkeley.edu> wrote:
> 
>      Hi,
> 
>      How can I bind certain layouts to key combinations? So rather than cycle
>      thorugh layouts with Mod Space, I'd like Mod F1 to give me layout 1, Mod
>      F2 to give me layout 2, etc... I've been googling for a bit, but can't
>      find an answer.
> 
>      Thanks.
> 
>      anze
> 
>    Hi Anze,
> 
>    You can do this using the JumpToLayout message from the
>    XMonad.Layout.LayoutCombinators extension module.  For example:
> 
>    import XMonad hiding ( (|||) )  -- don't use the normal ||| operator
>    import XMonad.Layout.LayoutCombinators   -- use the one from
>    LayoutCombinators instead
>    import XMonad.Util.EZConfig  -- add keybindings easily
> 
>    main = xmonad myConfig
> 
>    myConfig = defaultConfig {
>      ...
>      layoutHook = tall ||| Mirror tall ||| Full
>      ...
>    } `additionalKeysP`
>      [ ("M-<F1>", sendMessage $ JumpToLayout "Tall")
>      , ("M-<F2>", sendMessage $ JumpToLayout "Mirror Tall")
>      , ("M-<F3>", sendMessage $ JumpToLayout "Full")
>      ]
> 
>    tall = Tall 1 (3/100) (1/2)
> 
>    Untested, but that's the basic idea, hopefully that will get you going on
>    the right track.  Let us know if you've got more questions.
> 
>    -Brent
> 

Thanks Brent, I added this solution to the wiki:

    http://haskell.org/haskellwiki/Xmonad/General_xmonad.hs_config_tips#Binding_keys_to_a_specific_layout

-- Don


More information about the xmonad mailing list