add 'withNthWorkspace' to DynamicWorkspaceOrder.

Note this is very similar to the function of the same name exported by
DynamicWorkspaces.  Ultimately it would probably be cleaner to
generalize the one in DynamicWorkspaces to accept an arbitrary
workspace sort as a parameter; this is left as an exercise for future
hackers.
This commit is contained in:
jakob 2012-04-07 18:46:40 +00:00
parent c691988bbf
commit 7b21732ead

View File

@ -28,6 +28,8 @@ module XMonad.Actions.DynamicWorkspaceOrder
, moveToGreedy
, shiftTo
, withNthWorkspace
) where
import XMonad
@ -163,3 +165,14 @@ moveToGreedy dir t = doTo dir t getSortByOrder (windows . W.greedyView)
-- given type in the given direction, using the dynamic workspace order.
shiftTo :: Direction1D -> WSType -> X ()
shiftTo dir t = doTo dir t getSortByOrder (windows . W.shift)
-- | Do something with the nth workspace in the dynamic order. The
-- callback is given the workspace's tag as well as the @WindowSet@
-- of the workspace itself.
withNthWorkspace :: (String -> WindowSet -> WindowSet) -> Int -> X ()
withNthWorkspace job wnum = do
sort <- getSortByOrder
ws <- gets (map W.tag . sort . W.workspaces . windowset)
case drop wnum ws of
(w:_) -> windows $ job w
[] -> return ()