[Xmonad] Rotate window Stack

Hans Philipp Annen hpa at gmx.li
Wed Aug 1 18:55:13 EDT 2007


Hello List, 

I just recently found out about xmonad and I am addicted already :)
Thanks for this great window manager.

I have written a function that will rotate all windows in the stack
except the master, while leaving the focus where it is.
I use it with the TwoPane layout: In this layout, the first window after
the master window will be raised whenever the master gets the focus,
which I found annoying. 
If that window has the focus, and you use my rotateSlaves function to
change to another window, this window will still be visible when you
change the focus to the master window.
It is also nice to be able to change the window visible in the second
pane without loosing focus in the master window.

I was not sure whether I should put this in XMonadContrib, since I think
it's a candidate for Operations.hs.

Anyway, here is the function:


rotSlaves :: SS.StackSet i a s sd -> SS.StackSet i a s sd
rotSlaves = SS.modify' rotSlaves'

rotSlaves' :: SS.Stack a -> SS.Stack a
rotSlaves' (SS.Stack t ls rs) | (null ls) = SS.Stack t [] ((rearRs)++(frontRs))          --Master has focus
                              | otherwise = SS.Stack t' (reverse ((master)++revls')) rs' --otherwise
    where  (frontRs, rearRs) = splitAt (max 0 ((length rs) - 1) rs
           (ils, master)     = splitAt (max 0 ((length ls) - 1) ls
           toBeRotated       = (reverse ils)++(t:rs)
           (revls',t':rs')   = splitAt (length ils) ((last toBeRotated):(init toBeRotated))


a keybinding looks like:

  , ((modMask .|. shiftMask, xK_Tab   ), windows rotSlaves) 



I hope someone else will find that usefull...

Hans Philipp Annen

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.haskell.org/pipermail/xmonad/attachments/20070802/2edf21ee/attachment-0001.bin


More information about the Xmonad mailing list