这是 this question 的后续内容.
为了找出我有多少个物理显示器,我想出了
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 的理解犯了一些错误,而不是代码本身本身就不好,但我真的不确定。
最佳答案
我怀疑您想使用map show [0 .. n-1]
而不是map show [0 .. n]
。我还建议您在 main
中生成 xmobar 实例,而不是在 logHook
中,因为后者会在您每次执行任何 xmonad 操作(例如更改重点)。至于screenCount
,我可以建议countScreens来自 IndependentScreens
模块?
关于haskell - 由于我的 Xmonad 配置中存在与 IO 相关的问题,XMobar 即将崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5608415/