[xmonad] Configuring XMonad.Layout.Monitor

Roman Cheplyaka roma at ro-che.info
Sat Dec 27 16:44:10 EST 2008


* Richard Riley <rileyrgdev at googlemail.com> [2008-12-27 22:20:02+0100]
> 
> Roman Cheplyaka <roma at ro-che.info> writes:
> 
> > In order to simplify understanding and configuration of Monitor
> > extension, I made these (backwards-incompatible) changes:
> > - remove a bunch of add*Monitor functions
> > - added some new, so now monitor can be configured using three steps:
> >
> > 1. Define Monitor record. 'monitor' can be used as a template, so if you
> >    don't need some features (opacity, named monitors) or you're ok with
> >    default values you may not define corresponding fields (or even know
> >    about them).
> >
> >     clock = monitor
> >         { prop = ClassName "Cairo-clock" `And` Title "MacSlow's Cairo-Clock"
> >         , rect = (Rectangle (1280-150) (800-150) 150 150)
> >         , persistent = True
> >         , opacity = 0xAAAAAAAA
> >         }
> >
> > 2. Add ManageHook to de-manage monitor windows and apply opacity settings.
> >
> >     manageHook = myManageHook <+> manageMonitor clock
> >
> > 3. Apply layout modifier.
> >
> >     myLayouts = ModifiedLayout clock $ ...
> >
> > Please see updated documentation for details.
> >
> > To users who have already configured their monitors: all you need to
> > change is layout (define monitor and use ModifiedLayout instead of
> > addMonitor). You may leave manageHook as it is and it will work.
> > So conversion should be pretty easy. Sorry for the inconvenience.
> 
> This might be a silly question (not familiar with Haskell too well), but
> why not simply "register" Monitor objects in the monitor creation and
> then add a single hook and layout?
> 
> e.g something along the lines of (not real haskell!)
> 
> monitor( prop = Title "xclock"
>         , rect = (Rectangle (1280-150) (800-150) 150 150)
>         , persistent = True
>         , opacity = 0xAAAAAAAA
>         )
> 
> monitor(  prop = ClassName "procman"
>         , rect = (Rectangle (1280-150) (800-150) 150 150)
>         , persistent = True
>         , opacity = 0xAAAAAAAA
>         )
> 
> myLayouts = monitors $ ...
> 
> and
> 
> manageHook = monitorsHook <+>
> 
> 
> or is there a good reason to add each monitor to hooks and layouts
> separately?

Registering Monitor objects in the monitor creation is not possible
because Haskell is declarative pure language. Actually these statements
do not _create_ anything, they just _define_ monitors which you may (or
may not) use later. We prefer to be explicit about any possible effects.

This is the general reason. Another reason is that you may apply
different monitors to different layouts.

However, you can gather all defined monitors into a list (call it
'monitors') and define something like

  monitorsLayoutModifier = foldr (.) id $ map ModifiedLayout $ monitors
  monitorsManageHook = composeAll monitors

and then have what you wanted:

  myLayouts = monitorsLayoutModifier $ ...
  manageHook = monitorsManageHook <+>

If this way is more convenient for you, I can add these functions
monitorsLayoutModifier and monitorsManageHook into the module.

-- 
Roman I. Cheplyaka :: http://ro-che.info/
"Don't let school get in the way of your education." - Mark Twain


More information about the xmonad mailing list