[Xmonad] Show name of focused window in status bar

Lukas Mai l.mai at web.de
Tue Aug 21 17:26:37 EDT 2007


Am Dienstag, 21. August 2007 schrieb Kai Grossjohann:
> On Tue, Aug 21, 2007 at 06:09:45PM +0200, Lukas Mai wrote:
> > logHook = withWindowSet $ \ws -> do
> >     let d = pprWindowSet ws
> >     t <- maybe (return "") (liftM show . getName) (W.peek ws)
> >     io . putStrLn $ show t ++ d
>
> Way over my head.  I just know it works.  Thanks a lot.

Maybe this version is easier to understand (untested):

logHook = withWindowSet $ \ws -> do
    let d = pprWindowSet ws
    let maybeWindow = W.peek ws
    let action = case maybeWindow of
        Nothing -> return ""
        Just window -> do
           namedWindow <- getName window
           return (show namedWindow)
    t <- action
    io (putStrLn (show t ++ d))

HTH, Lukas


More information about the Xmonad mailing list