[xmonad] separate log for each Xinerama screen

Oleksandr Manzyuk manzyuk at gmail.com
Wed Nov 10 17:10:08 EST 2010

Hello all,

I've been experimenting with XMonad recently and I've come up with a
solution to the following "problem": I have a dual-head setup and am
running two status bars on the top of each screen; I would like to be
able to display in each status bar the information that is relevant to
the corresponding screen.  In particular, when I am moving the focus
around, staying on one screen, the window title shown in the status
bar of that screen should be changing according to the focused window,
while that shown in the status bar on the other screen should not and
should show the title of the window that would have the focus if I
switched to the other screen.  Similarly for layouts.  On the other
hand, both status bars should show the same list of hidden non-empty
workspaces.  This way, when I'm doing something on a particular screen
I don't have to turn my head to find out which workspace I am on and
what is my current layout.  The solution I have is sufficiently
general, so that I thought it could be added to
XMonad.Hooks.DynamicLog module.  In that module there are functions
dynamicLogWithPP, dynamicLogString, and pprWindowSet that operate on
the current screen;  I wrote the functions dynamicLogWithPP',
dynamicLogString', and pprWindowSet' that are like their undashed
counterparts but take the screen to operate on as the first argument.
This way I can do

xmobar screen template commands = spawnPipe . intercalate " " $ options
   where options = [ "xmobar"
                   , "-x"
                   , show screen
                   , "-t"
                   , wrap "'" "'" template
                   , "-c"
                   , wrap "'" "'" commands

main = do
  xmobar0 <- xmobar 0 "%StdinReader%}{"       "[Run StdinReader]"
  xmobar1 <- xmobar 1 "%StdinReader%}{%date%" "[Run StdinReader, Run
Date \"%a %b %_d, %H:%M\" \"date\" 10]"
  xmonad $ defaultConfig {
             , logHook = myLogHook [ pp { ppOutput = hPutStrLn xmobar0 }
                                   , pp { ppOutput = hPutStrLn xmobar1 }

myLogHook pps = do
  screens <- (sortBy (compare `on` S.screen) . S.screens) `fmap` gets windowset
  zipWithM_ dynamicLogWithPP' screens pps

and be happy!  If you are interested, please see
https://github.com/manzyuk/dotfiles for details.  I don't know if this
is a valuable addition, but it works very well for me, so I thought I
would share.


More information about the xmonad mailing list