Search code examples
xmonad

How to toggle multiple master windows orientation


I'm using the following XMonad.Layout.ThreeColumns layout

-----------------------------------
|        |               |        |    
|        |               |        |
|        |               |        |
|--------|     Master    |--------|  
|        |               |        |  
|        |               |        | 
|        |               |        |
-----------------------------------

when I use sendMessage (IncMaster 1) via hotkey it splits Master window horizontally

-----------------------------------
|        |               |        |    
|        |    Master 1   |        |
|        |               |        |
|--------|---------------|--------|  
|        |               |        |  
|        |    Master 2   |        | 
|        |               |        |
-----------------------------------

How to split it vertically or toggle it to vertical orientation? To make it like this:

-------------------------------------
|        |        |        |        |    
|        |        |        |        |
|        |        |        |        |
|--------|Master 1|Master 2|--------|  
|        |        |        |        |
|        |        |        |        |
|        |        |        |        |
-------------------------------------

Solution

  • Solved by forking Layout and hard coding it to split vertically:

    mkdir -p ~/.xmonad/lib/XMonad/Layout
    wget "https://raw.githubusercontent.com/xmonad/xmonad-contrib/master/XMonad/Layout/ThreeColumns.hs" -o ~/.xmonad/lib/XMonad/Layout/My.hs
    

    Change module name:

    module XMonad.Layout.My 
    

    Fix importing XMonad.Prelude module problems:

    -- import XMonad.Prelude
    import Control.Monad (ap, msum)
    

    Change behavior from this:

    tile3 middle f r nmaster n
        | n <= nmaster || nmaster == 0 = splitVertically n r
        | n <= nmaster+1 = splitVertically nmaster s1 ++ splitVertically (n-nmaster) s2
        | otherwise = splitVertically nmaster r1 ++ splitVertically nslave1 r2 ++ splitVertically nslave2 r3
    

    to this:

    tile3 middle f r nmaster n
        | n <= nmaster || nmaster == 0 = splitHorizontally n r
        | n <= nmaster+1 = splitVertically nmaster s1 ++ splitVertically (n-nmaster) s2
        | otherwise = splitHorizontally nmaster r1 ++ splitVertically nslave1 r2 ++ splitVertically nslave2 r3
    

    ~/.xmonad/xmonad.hs:

    --import XMonad.Layout.ThreeColumns
    import XMonad.Layout.My