XMonad (or xmonad-contrib) function to read current layout name?

96 Views Asked by At

Say I have an XMonad layout that I named "foo" via XMonad.Layout.Renamed.

I've got a keybinding that I would like bound to a different X () depending on the current layout of the focused workspace. For example, something along the lines of:

case () of
() | currentLayoutName == "foo" -> fooAction
   | otherwise                  -> barAction

..but how can I implement currentLayoutName?

1

There are 1 best solutions below

1
On BEST ANSWER

Just traverse down the StackSet to the current workspace to the layout description.

-- Imports
…
import qualified XMonad.StackSet as W
…

-- Key bindings
…
, ((modm, xK_F1), do
    wset <- gets windowset
    let ldesc = description . W.layout . W.workspace . W.current $ wset
    case ldesc of
        "foo" -> fooAction
        _     -> barAction
  )
…