Search code examples
xmonad

How to get the index of a Window in the Stackset within XMonad?


How can I get the index of a Window within a StackSet?

I've haad a look through http://hackage.haskell.org/package/xmonad-0.13/docs/XMonad-StackSet.html but can't find anything relevent.


Solution

  • import qualified XMonad.StackSet as W
    import XMonad.StackSet
    import Data.List (elemIndex)
    
    
    windowIndex :: Window -> StackSet i l Window s sd -> Maybe Int
    windowIndex w s = elemIndex w $ allWindowsInCurrentWorkspace s
    
    
    allWindowsInCurrentWorkspace :: W.StackSet i l a sid sd -> [a]
    allWindowsInCurrentWorkspace ws =
      W.integrate' . W.stack . W.workspace . W.current $ ws