[xmonad] Retrieve number of screens.

Mike Sampson mike at sambodata.com
Fri Nov 27 19:20:53 EST 2009


How do you retrieve the number of screens currently being used. I have tried:

screenCount :: Int
screenCount = do
    wsx <- gets windowset
    return (length (W.screens wsx))

however it gives an error:

xmonad.hs:60:4:
    Couldn't match expected type `Int' against inferred type `m b'
    In a stmt of a 'do' expression: wsx <- gets windowset
    In the expression:
        do wsx <- gets windowset
           return (length (W.screens wsx))
    In the definition of `screenCount':
        screenCount = do wsx <- gets windowset
                         return (length (W.screens wsx))

I used XMonad.Actions.CycleWS's screenBy as a guide:

screenBy :: Int -> X (ScreenId)
screenBy d = do ws <- gets windowset
                --let ss = sortBy screen (screens ws)
                let now = screen (current ws)
                return $ (now + fromIntegral d) `mod` fromIntegral
(length (screens ws))

Regards,

Mike


More information about the xmonad mailing list