diff options
author | Devin Mullins <me@twifkak.com> | 2007-10-02 23:24:07 +0200 |
---|---|---|
committer | Devin Mullins <me@twifkak.com> | 2007-10-02 23:24:07 +0200 |
commit | 5784590478cbdb1d0853fcf50a1ac13602a51895 (patch) | |
tree | f0a59e3b2423c175956a2723bb5af04a331c62bc | |
parent | 2f5252ad19893c0c06508b7e957b3bf65df43436 (diff) | |
download | XMonadContrib-5784590478cbdb1d0853fcf50a1ac13602a51895.tar.gz XMonadContrib-5784590478cbdb1d0853fcf50a1ac13602a51895.tar.xz XMonadContrib-5784590478cbdb1d0853fcf50a1ac13602a51895.zip |
add SwapWorkspaces (to reorder them on your number keys)
darcs-hash:20071002212407-78224-eef85cd29ff04e0d352aeba89273e67e57e2fa46.gz
-rw-r--r-- | SwapWorkspaces.hs | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/SwapWorkspaces.hs b/SwapWorkspaces.hs new file mode 100644 index 0000000..e1575dc --- /dev/null +++ b/SwapWorkspaces.hs @@ -0,0 +1,52 @@ +----------------------------------------------------------------------------- +-- | +-- Module : XMonadContrib.SwapWorkspaces +-- Copyright : (c) Devin Mullins <me@twifkak.com> +-- License : BSD3-style (see LICENSE) +-- +-- Maintainer : Devin Mullins <me@twifkak.com> +-- Stability : unstable +-- Portability : unportable +-- +-- Lets you swap workspace tags, so you can keep related ones next to +-- each other, without having to move individual windows. +-- +-- TODO: add quickcheck props for: +-- * double swap invariant (guarantees no 'loss' of workspaces) +-- * non-swapped ws's invariant +-- +----------------------------------------------------------------------------- + +module XMonadContrib.SwapWorkspaces ( + -- * Usage + -- $usage + swapWithCurrent, + swapWorkspaces + ) where + +import StackSet + +-- $usage +-- Add this import to your Config.hs: +-- > import XMonadContrib.SwapWorkspaces +-- +-- Throw this in your keys definition: +-- > ++ +-- > [((modMask .|. controlMask, k), windows $ swapWithCurrent i) +-- > | (i, k) <- zip workspaces [xK_1 ..]] + +swapWithCurrent :: Eq i => i -> StackSet i l a s sd -> StackSet i l a s sd +swapWithCurrent t s = swapWorkspaces t (tag $ workspace $ current s) s + +-- Stole this from StackSet.renameTag -- extracted the traversal code they have in common as mapWorkspaces +swapWorkspaces :: Eq i => i -> i -> StackSet i l a s sd -> StackSet i l a s sd +swapWorkspaces t1 t2 = mapWorkspaces swap + where swap w = if tag w == t1 then w { tag = t2 } + else if tag w == t2 then w { tag = t1 } + else w + +mapWorkspaces :: (Workspace i l a -> Workspace i l a) -> StackSet i l a s sd -> StackSet i l a s sd +mapWorkspaces f s = s { current = updScr $ current s + , visible = map updScr $ visible s + , hidden = map f $ hidden s } + where updScr scr = scr { workspace = f $ workspace scr } |