[Xmonad] Re: darcs patch: add LayoutChoice module.

Tassilo Horn tassilo at member.fsf.org
Fri Sep 7 16:57:26 EDT 2007


Hi all,

for anyone interested, that's how I use LayoutChoice with a prompt to
select a layout algorithm by name.

--8<---------------cut here---------------start------------->8---
myNamedLayouts :: [(String, Layout Window)]
myNamedLayouts = [ ("tiled", tiled)
                 , ("mirror-tiled", mirror tiled)
                 , ("tabbed", tabbed shrinkText myTConf)
                 , ("two-pane-combo"
                   , simpleStacking $
                    combo (twoPane delta (1%2)) [(full,1)
                                                ,(tabbed shrinkText
                                                         defaultTConf, 1)])
                 ]
    where
      -- default tiling algorithm partitions the screen into two panes
      tiled   = tall nmaster delta ratio

      -- The default number of windows in the master pane
      nmaster = 1

      -- Default proportion of screen occupied by master pane
      ratio   = 1%2

      -- Percent of screen to increment by when resizing panes
      delta   = 2%100

      -- the tabbed configuration to use for the tabbed layout
      myTConf = defaultTConf { tabSize = 15
                             , fontName = "-misc-fixed-medium-r-*-*-13-*-*-*-*-*-*-*"
                             }

data LayoutPrompt = LayoutPrompt

instance XPrompt LayoutPrompt where
    showXPrompt LayoutPrompt = "Layout:   "

layoutPrompt :: XPConfig -> X ()
layoutPrompt c = mkXPrompt LayoutPrompt c
                 (mkComplFunFromList (map fst myNamedLayouts))
                 (sendMessage . JumpToLayout)

defaultLayouts :: [Layout Window]
defaultLayouts = [ layoutChoice myNamedLayouts ]
--8<---------------cut here---------------end--------------->8---

I don't bind any keys to cycle to the layouts anymore, but only the
prompt.

--8<---------------cut here---------------start------------->8---
keys = M.fromList $
    -- launching and killing programs
    [ ...
      ...
      , ((modMask, xK_space ), layoutPrompt myXPConfig)
      ...
    ]
--8<---------------cut here---------------end--------------->8---

Bye,
Tassilo



More information about the Xmonad mailing list