[xmonad] Reset layout to default on last window close

Brandon Allbery allbery.b at gmail.com
Tue Feb 28 21:18:24 CET 2012

On Tue, Feb 28, 2012 at 10:44, Alexander Batischev <eual.jp at gmail.com>wrote:

> I want workspace layout to reset to some default once last window is
> closed. Quick glance though Xmonad-related modules names didn't give me
> any hints on what hook (or some other facility) to use, so I'm seeking
> your advice, fellow Xmonaders: how can I accomplish that?

Use XMonad.Layout.LayoutCombinators; you want its version of the (|||)
operator so you can send the JumpToLayout message.

Beyond that, you want to use a handleEventHook which matches
DestroyWindowEvent and checks the contents of the current workspace; if
only one window is present, send the JumpToLayout message.  It should end
up being something like this (untested):

> import XMonad hiding (|||)
> import XMonad.Layout.LayoutCombinators
> import qualified XMonad.StackSet as W
> import Data.Monoid -- for All
> handleEventHook DestroyWindowEvent {} =
>   n <- (length . index) `fmap` withWindowSet
>   guard (n == 1) $ sendMessage $ JumpToLayout "name of initial layout
>   return (All True)

brandon s allbery                                      allbery.b at gmail.com
wandering unix systems administrator (available)     (412) 475-9364 vm/sms
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/xmonad/attachments/20120228/967ba656/attachment-0001.htm>

More information about the xmonad mailing list