Search code examples
xmonad

How to generate this kind of xmonad tiling


How can I generate this kind of tiling with xmonad?

http://xmonad.org/images/screen-ejt-spiral-dzen.png

I know you can increase/decrease the number of windows in the master pane with mod-comma, and use mod-space mod-h and mod-l to change the layout. But it seems like just those set of commands cannot reproduce the kind of tiling in the above link.

In particular, there are two things I just don't know how to do that the link above does:

  1. The larger tile on the right is not split horizontally in the middle, but is actually longer. I can only increase/decrease the master pane like that using mod-h and mod-l
  2. The smaller tile on the right is split into two subtiles. I have no idea how you would even go about this with xmonad

Solution

  • You need to create a new layout in your .xmonad/xmonad.hs For this you need to have a little experience with haskell.

    I've created a fullscreen Layout which can be used by pressing a specific key combination here's an example:

    import the following:

    import XMonad.Layout.Spacing
    import XMonad.Layout.LayoutCombinators hiding ( (|||) )
    import XMonad.Layout.Fullscreen
    import XMonad.Layout.NoBorders
    import XMonad.Layout.Reflect
    import XMonad.Layout.Combo
    import XMonad.Layout.TwoPane
    import XMonad.Layout.Tabbed 
    import XMonad.Layout.PerWorkspace
    import XMonad.Layout.IM
    import XMonad.Layout.ThreeColumns
    

    And then you could do something like this:

    sPx = 1
    
    verticalLayout = spacing sPx $ avoidStruts $ reflectHoriz $ Tall 1 0.03 0.5
    verticalLayoutLargeScreen = spacing sPx $ avoidStruts $ ThreeCol 1 0.03 0.5
    horizontalLayout = spacing sPx $ avoidStruts $ Mirror $ Tall 1 0.03 0.5
    webdevLayout = spacing sPx $ avoidStruts $ Tall 1 0.03 0.63
    fullscreenLayout = noBorders $ fullscreenFull $ Full
    
    myLayout =
        onWorkspace "2:web" (webdevLayout ||| fullscreenLayout) $
                        (verticalLayout ||| horizontalLayout ||| fullscreenLayout)
    

    After this define a mapping for your key combo:

    myAdditionalKeys = [
      -- Switch to next layout:
      ((mod4Mask .|. shiftMask, xK_m), sendMessage NextLayout),
    ]
    

    and then do not forget to add your layout and your key Mapping to the config, could look like this:

    main = do
      xmonad $ defaultConfig
                 { manageHook = manageSpawn <+> myManageHook <+> manageDocks,
                   layoutHook = myLayout,
                   logHook = dynamicLogWithPP xmobarPP {
                           ppOutput = hPutStrLn xmproc,
                           ppLayout = (\ x -> ""),
                           ppTitle = xmobarColor "#b2ed00" ""
                         } >> updatePointer (Relative 0.99 0.99),
                   modMask = mod4Mask,
                   borderWidth = 4,
                   normalBorderColor = "#777777",
                   focusedBorderColor = "#ccff00",
                   workspaces = myWorkspaces,
                   focusFollowsMouse = True,
                   terminal = "x-terminal-emulator"
                 }
                 `removeKeys` myRemoveKeys
                 `additionalKeys` myAdditionalKeys