这是对这个问题的跟进。
为了试图找出我有多少物理显示器,我想出了
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 只是进入xmonad $ DefaultConfig
. 但是,当我加载 XMonad 时,顶部 XMobars 的 PipeReader(在两个屏幕上)只显示updating
了一会儿,然后消失,并且在我重新加载时拒绝回来。底层的人非常高兴。
以前,我只是用于我的 ppOutput:
ppOutput = \x -> hPutStrLn xmobarTopScreen0 x >> hPutStrLn xmobarTopScreen1 x
效果很好。
我假设我对 IO 的理解犯了一些错误,而不是代码本身不好,但我真的不确定。