aboutsummaryrefslogtreecommitdiffstats
path: root/XMonad
diff options
context:
space:
mode:
authorjakob <jakob@pipefour.org>2012-04-07 20:46:40 +0200
committerjakob <jakob@pipefour.org>2012-04-07 20:46:40 +0200
commit3a76a42151c6bd701e3d255aa0f5d38f4c2b034f (patch)
tree8bb29d489f9eae0013052ad1d04257539a11b88c /XMonad
parent0977895c959f633a2d8cc9add20aa270a3b467f6 (diff)
downloadXMonadContrib-3a76a42151c6bd701e3d255aa0f5d38f4c2b034f.tar.gz
XMonadContrib-3a76a42151c6bd701e3d255aa0f5d38f4c2b034f.tar.xz
XMonadContrib-3a76a42151c6bd701e3d255aa0f5d38f4c2b034f.zip
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
Diffstat (limited to 'XMonad')
-rw-r--r--XMonad/Actions/DynamicWorkspaceOrder.hs15
1 files changed, 14 insertions, 1 deletions
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