我终于明白了!
我的xmonad.hs的相应部分:
import Data.IORef
import XMonad.Layout.Monitor
myClckMonitor = monitor
{ prop = ClassName "DockApp" `And` Title "wmclockmon"
, rect = Rectangle (1680 - 64) 0 64 64
, persistent = False
, name = "clock"
}
screenRectEventHook :: Event -> X All
screenRectEventHook CrossingEvent { ev_window = win } = do
dpy <- asks display
root <- asks theRoot
(posX, posY, acc) <- io $ do
-- queryPointer :: Display -> Window -> IO (Bool, Window, Window, Int, Int, Int, Int, Modifier)
-- interface to the X11 library function XQueryPointer().
(_, _, _, ix, iy, _, _, _) <- queryPointer dpy root
r <- newIORef Nothing
return (fromIntegral ix, fromIntegral iy, r)
if (posY < 64 && posX > (1680 - 64))
then do
broadcastMessage HideMonitor >> refresh
return (All True)
else do
broadcastMessage ShowMonitor >> refresh
return (All True)
screenRectEventHook _ = return (All True)
然后注册事件挂钩:
myEventHook e = do
screenRectEventHook e
return (All True)
如您所见,我的显示器的坐标是硬编码的!如何重新显示时钟的问题仍然悬而未决。但是,如果您切换工作区或切换到另一个窗口,它将再次可见。这对我来说已经足够了。