I'm running XMonad on a laptop that I sometimes, but not always, have an additional monitor attached. I'd like to detect the number of screens in my xmonad.hs
have a instance of XMobar per screen.
I've seen this question and answer, but I've not really got my head around monad transformers and how to make use of a value of type X [Rectangle]
.
Right now, I have, roughly, this:
import XMonad
import XMonad.Config.Desktop
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Util.Run(spawnPipe)
import XMonad.Core (X ,withDisplay ,io)
import Graphics.X11.Xinerama (getScreenInfo)
import Graphics.X11.Xlib.Types (Rectangle)
import System.IO
xdisplays :: X [Rectangle]
xdisplays = withDisplay $ io . getScreenInfo
main = do
xmproc <- spawnPipe "/usr/bin/xmobar /home/liam/.xmobarrc"
xmonad $ desktopConfig
{ layoutHook = avoidStruts $ layoutHook defaultConfig,
manageHook = manageHook defaultConfig <+> manageDocks,
logHook = dynamicLogWithPP xmobarPP
{ ppOutput = hPutStrLn xmproc
}
}
Naively, I'd like to put rects <- xdisplays
at the start of my do block, then spawn xmobar instances appropriately, but obviously this doesn't work because the type is X [Rectangle]
not IO [Rectangle]
. I wondered if I need to use runX somehow?