
Hi, I have been using xmonad for a long while now and really like it. Unfortunately Haskell is still mostly a mystery to me, so this might be trivial. I use the Tall Layout, configured like this: myLayout = smartBorders (configurableNavigation noNavigateBorders $ (tiled) ||| Full) where tiled = Tall nmaster delta ratio nmaster = 2 ratio = 1/2 delta = 3/100 This gives me the following layout: 1 window 2 3 4 6 ___________ ___________ ___________ ___________ ___________ | | | | | | | | | | | |----| | | |---------| |----| | |----|----| |----|----| | | | | | | | | | | | |----| ----------- ----------- ----------- ----------- ----------- When I have 2 windows I would like to split vertically instead. Especially on a widescreen laptop monitor the current layout is not good for things like terminals where I really only need 80 characters. How can I get something like this instead?: ___________ ___________ ___________ ___________ ___________ | | | | | | | | | | | | |----| | | | | | | |----| |----|----| |----|----| | | | | | | | | | | | | |----| ----------- ----------- ----------- ----------- ----------- If I could somehow set nmaster to 1 when number of windows is less than 4 I guess that would do the trick. Kind Regards, Pär Andersson

Hi, Pär Andersson wrote:
Hi,
If I could somehow set nmaster to 1 when number of windows is less than 4 I guess that would do the trick.
Not the perfect solution but you can change the number of master windows on-the-fly using bindings like these: ((modMask x .|. shiftMask, xK_comma ), sendMessage (IncMasterN 1 )) ((modMask x .|. shiftMask, xK_period), sendMessage (IncMasterN (-1))) (IncMasterN is in package XMonad.Layout) Cheers, Zsolt

* On Thursday, July 16 2009, Pär Andersson wrote:
Hi,
...
If I could somehow set nmaster to 1 when number of windows is less than 4 I guess that would do the trick.
First I thought of using a logHook to update the layout:
setNMaster :: X () setNMaster = do n <- gets $ length . W.integrate' . W.stack . W.workspace . W.current . windowset if n >= 4 then sendMessage (IncMasterN 1) else sendMessage (IncMasterN (-1))
But that would only work if we had a message to /set/ the nmaster, which we don't. And I'd expect there to be some infinite loops, since sendMessage will trigger another refresh, which will run the loghook again, and so on. A more messy option that should work is to define a layout in terms of Tall, which sets nmaster according to your specification:
{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses #-} import XMonad import qualified XMonad.StackSet as W
data TallAlt a = TallAlt { tallAltIncrement :: !Rational, tallAltRatio :: !Rational } deriving (Read, Show)
instance LayoutClass TallAlt a where -- this would be more cleanly done with pureLayout, but Tall has no contract that it will remain pure doLayout (TallAlt i d) r st = fmap (\(x,_) -> (x,Nothing)) $ doLayout (Tall nmaster i d) r st where nmaster | stlen > 3 = 2 | otherwise = 1 stlen = length $ W.integrate st pureMessage (TallAlt i d) m = (`fmap` fromMessage m) $ \x -> case x of Expand -> TallAlt i (d+i) Shrink -> TallAlt i (d-i)
Which you can then use with something like:
myLayout = smartBorders (configurableNavigation noNavigateBorders $ (tiled) ||| Full) where tiled = TallAlt delta ratio ratio = 1/2 delta = 3/100
Note, I didn't test this, though it does typecheck. I think that you might be better served by layouts that take more freedom in laying windows out, such as Mosaic, MosaicAlt, or any Resizable* variants, however. Adam

Adam Vogt
A more messy option that should work is to define a layout in terms of Tall, which sets nmaster according to your specification: <snip> Note, I didn't test this, though it does typecheck.
I am using it now, it works.
I think that you might be better served by layouts that take more freedom in laying windows out, such as Mosaic, MosaicAlt, or any Resizable* variants, however.
I will have a look at those when I get the time. But for now I am quite happy with this TallAlt layout, thanks for the help. Thanks Zsolt for the IncMasterN suggestion also. Regards, -- Pär Andersson

Depending how adamant you are about the layout of higher numbers of windows, you might find Grid to be satisfying in some ways. ~d
participants (4)
-
Adam Vogt
-
paran@lysator.liu.se
-
wagnerdm@seas.upenn.edu
-
Zsolt Dollenstein