From 3a76a42151c6bd701e3d255aa0f5d38f4c2b034f Mon Sep 17 00:00:00 2001 From: jakob Date: Sat, 7 Apr 2012 20:46:40 +0200 Subject: add 'withNthWorkspace' to DynamicWorkspaceOrder. Ignore-this: f5f87ffe9ddf1a12fab775e6fb8e856f 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. darcs-hash:20120407184640-b9182-99b3857ef415af2bc9a6bbbc22388145e0145126.gz --- XMonad/Actions/DynamicWorkspaceOrder.hs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'XMonad/Actions') diff --git a/XMonad/Actions/DynamicWorkspaceOrder.hs b/XMonad/Actions/DynamicWorkspaceOrder.hs index 04ddcf5..75f16ee 100644 --- a/XMonad/Actions/DynamicWorkspaceOrder.hs +++ b/XMonad/Actions/DynamicWorkspaceOrder.hs @@ -28,6 +28,8 @@ module XMonad.Actions.DynamicWorkspaceOrder , moveToGreedy , shiftTo + , withNthWorkspace + ) where import XMonad @@ -162,4 +164,15 @@ moveToGreedy dir t = doTo dir t getSortByOrder (windows . W.greedyView) -- | Shift the currently focused window to the next workspace of the -- 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) \ No newline at end of file +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 () \ No newline at end of file -- cgit v1.2.3