diff options
author | David Roundy <droundy@darcs.net> | 2007-10-17 01:03:01 +0200 |
---|---|---|
committer | David Roundy <droundy@darcs.net> | 2007-10-17 01:03:01 +0200 |
commit | c6a85d16114d218fad10f6e611ddd30d701ec67c (patch) | |
tree | cf0e7ef6b7973226afd2dcdf12198c91ee1372a8 | |
parent | d1587d44209f924682f25dffff584d6e052029a4 (diff) | |
download | XMonadContrib-c6a85d16114d218fad10f6e611ddd30d701ec67c.tar.gz XMonadContrib-c6a85d16114d218fad10f6e611ddd30d701ec67c.tar.xz XMonadContrib-c6a85d16114d218fad10f6e611ddd30d701ec67c.zip |
allow users to go to dynamically-added workspaces with mod-n.
darcs-hash:20071016230301-72aca-e003c298f830d89d4125c5d15accb4ed71bc6241.gz
-rw-r--r-- | DynamicWorkspaces.hs | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/DynamicWorkspaces.hs b/DynamicWorkspaces.hs index e9bd06c..81c9686 100644 --- a/DynamicWorkspaces.hs +++ b/DynamicWorkspaces.hs @@ -17,12 +17,14 @@ module XMonadContrib.DynamicWorkspaces ( -- * Usage -- $usage addWorkspace, removeWorkspace, - selectWorkspace + selectWorkspace, + toNthWorkspace, withNthWorkspace ) where import Control.Monad.State ( gets ) +import Data.List ( sort ) -import XMonad ( X, XState(..), Layout, WorkspaceId ) +import XMonad ( X, XState(..), Layout, WorkspaceId, WindowSet ) import Operations import StackSet hiding (filter, modify, delete) import Graphics.X11.Xlib ( Window ) @@ -36,10 +38,29 @@ import XMonadContrib.XPrompt ( XPConfig ) -- -- > , ((modMask .|. shiftMask, xK_n), selectWorkspace defaultXPConfig layoutHook) -- > , ((modMask .|. shiftMask, xK_BackSpace), removeWorkspace) +-- +-- > -- mod-[1..9] %! Switch to workspace N +-- > -- mod-shift-[1..9] %! Move client to workspace N +-- > ++ +-- > zip (zip (repeat modMask) [xK_1..xK_9]) (map (withNthWorkspace W.greedyView) [0..]) +-- > ++ +-- > zip (zip (repeat (modMask .|. shiftMask)) [xK_1..xK_9]) (map (withNthWorkspace W.shift) [0..]) allPossibleTags :: [WorkspaceId] allPossibleTags = map (:"") ['0'..] +toNthWorkspace :: (String -> X ()) -> Int -> X () +toNthWorkspace job wnum = do ws <- gets (sort . map tag . workspaces . windowset) + case drop wnum ws of + (w:_) -> job w + [] -> return () + +withNthWorkspace :: (String -> WindowSet -> WindowSet) -> Int -> X () +withNthWorkspace job wnum = do ws <- gets (sort . map tag . workspaces . windowset) + case drop wnum ws of + (w:_) -> windows $ job w + [] -> return () + selectWorkspace :: XPConfig -> Layout Window -> X () selectWorkspace conf l = workspacePrompt conf $ \w -> do s <- gets windowset |