Xmonad, How to set up a grid of workspaces?

0

I want to have 9 workspaces as a grid. And to navigate them using the arrow-keys. So far I can navigate with the arrow-keys, but I want to get rid of the "wrap-around". For example, if workspace 9 is the current workspace and I press arrow UP, I end up with workspace 1(should stay on workspace 9). This should be no problem to implement if there is a way to get the current workspace.

Here is some of my code so far:

 myKeys = [ 
      , ((myModMask , xK_Down), (switchWorkspace (-3)))  -- prevWS 
      , ((myModMask , xK_Up), (switchWorkspace 3))    -- nextWS
      , ((myModMask , xK_Left), prevWS)
      , ((myModMask , xK_Right), nextWS)
      ]

 switchWorkspace :: Int -> X ()
 switchWorkspace d = wsBy d >>= windows . W.greedyView

 wsBy :: Int -> X (WorkspaceId)
 wsBy = findWorkspace C.getSortByIndex Next AnyWS

I found this code below which might be useful but don't know how to "extract" the result or if the result is useful? How do I get the current workspace? Thank you.

   -- | Lookup the index of a workspace id in the user's config, return Nothing
  -- if that workspace does not exist in the config.
 getWsIndex :: X (WorkspaceId -> Maybe Int)
 getWsIndex = do
     spaces <- asks (workspaces . config)
     return $ flip elemIndex spaces 

datamoose

Posted 2019-03-19T21:15:57.370

Reputation: 11

Answers

0

You can get the current workspace with logCurrent

https://hackage.haskell.org/package/xmonad-contrib-0.15/docs/XMonad-Util-Loggers.html#v:logCurrent

So instead of nextWS do:

do
  x <- logCurrent
  if x /= "9" then nextWS else pure ()

Chris Stryczynski

Posted 2019-03-19T21:15:57.370

Reputation: 121