[xmonad] Determining layout based on display properties

wagnerdm at seas.upenn.edu wagnerdm at seas.upenn.edu
Thu Apr 21 01:11:01 CEST 2011


Quoting Samir Unni <srunni at gmail.com>:

> I was wondering if there's a way to change the workspace layout based on the
> properties of the display (i.e., resolution). I'm trying to use a three
>
> This doesn't have to be dynamic - if the workspace layouts are set once when
> xmonad is launched based on which monitors are in use, that would be fine.

This is definitely possible. If you import Graphics.X11.Xlib and  
Graphics.X11.Xinerama, then the following snippet will give you a list  
of rectangles describing the currently-attached screens:

openDisplay "" >>= getScreenInfo

So, for example, you might do something like this:

main = do
   rects <- openDisplay "" >>= getScreenInfo
   case rects of
     [Rectangle {rect_width = 1600, rect_height=1200}] -> xmonad  
configForBigScreen
     _ -> xmonad fallbackConfig

Of course, there are many other options: you can do the dispatching in  
your startupHook rather than in main, for example, if you want to use  
the display that xmonad opens rather than opening your own, or you  
might even do something in your eventHook if you want it to adjust  
dynamically. Let us know if you'd like some more pointers.

~d



More information about the xmonad mailing list