This is a follow up to this question.
In pursuit of trying to find how many physical monitors I had, I came up with
screenCount :: X Int
screenCount = withDisplay (io.fmap length.getScreenInfo)
makeXMobars :: X [Handle] -- loads two xmobars per screen, one top & one bottom
makeXMobars = screenCount >>= (io.mapM spawnPipe.commandHandles )
where
commandHandles n = map ((\x -> "xmobar -x " ++ x).unwords) $ commandNames n
commandNames n = sequence [map show [0..n], map (\x -> "~/.xmobarrc" ++ x) ["Top", "Bottom"]]
myLogHook :: X ()
myLogHook = do
handles <- makeXMobars
dynamicLogWithPP $ defaultPP
{
ppOutput = \x -> mapM_ (`hPutStrLn` x) handles
}
myLogHook just drops in to the xmonad $ DefaultConfig
. However, when I load XMonad the PipeReader for the top XMobars (on both screens) just shows updating
for a little while, and then disappears, and refuses to come back when I reload. The bottom ones are perfectly happy.
Previously, I simply used for my ppOutput:
ppOutput = \x -> hPutStrLn xmobarTopScreen0 x >> hPutStrLn xmobarTopScreen1 x
which worked perfectly fine.
I assume I've made some error with my understanding of IO, rather than the code itself being bad per se, but I'm really not sure.