aboutsummaryrefslogtreecommitdiffstats
path: root/DynamicWorkspaces.hs
diff options
context:
space:
mode:
authorDavid Roundy <droundy@darcs.net>2007-08-14 03:15:01 +0200
committerDavid Roundy <droundy@darcs.net>2007-08-14 03:15:01 +0200
commitd444f374b6904bde4a10531f0161f367c8b54fb1 (patch)
tree02d589650814ca6a3badad42031c8c853a1e41a9 /DynamicWorkspaces.hs
parent197d10a9464bda62909e94a5aab0ad1599dc6535 (diff)
downloadXMonadContrib-d444f374b6904bde4a10531f0161f367c8b54fb1.tar.gz
XMonadContrib-d444f374b6904bde4a10531f0161f367c8b54fb1.tar.xz
XMonadContrib-d444f374b6904bde4a10531f0161f367c8b54fb1.zip
new module DynamicWorkspaces to add and remove workspaces.
darcs-hash:20070814011501-72aca-10aa9dd1a14ac1179f8cc16ebd52b1e54a505df8.gz
Diffstat (limited to 'DynamicWorkspaces.hs')
-rw-r--r--DynamicWorkspaces.hs52
1 files changed, 52 insertions, 0 deletions
diff --git a/DynamicWorkspaces.hs b/DynamicWorkspaces.hs
new file mode 100644
index 0000000..0f417bb
--- /dev/null
+++ b/DynamicWorkspaces.hs
@@ -0,0 +1,52 @@
+-----------------------------------------------------------------------------
+-- |
+-- Module : XMonadContrib.DynamicWorkspaces
+-- Copyright : (c) David Roundy <droundy@darcs.net>
+-- License : BSD3-style (see LICENSE)
+--
+-- Maintainer : David Roundy <droundy@darcs.net>
+-- Stability : unstable
+-- Portability : unportable
+--
+-- Provides bindings to add and delete workspaces. Note that you may only
+-- delete a workspace that is already empty.
+--
+-----------------------------------------------------------------------------
+
+module XMonadContrib.DynamicWorkspaces (
+ -- * Usage
+ -- $usage
+ addWorkspace, removeWorkspace
+ ) where
+
+import XMonad ( X )
+import Operations ( windows )
+import StackSet ( tagMember, StackSet(..), Screen(..), Workspace(..) )
+
+-- $usage
+-- You can use this module with the following in your Config.hs file:
+--
+-- > import XMonadContrib.DynamicWorkspaces
+--
+-- > , ((modMask .|. shiftMask, xK_Up), addWorkspace)
+-- > , ((modMask .|. shiftMask, xK_Down), removeWorkspace)
+
+addWorkspace :: X ()
+addWorkspace = windows addWorkspace'
+
+removeWorkspace :: X ()
+removeWorkspace = windows removeWorkspace'
+
+addWorkspace' :: (Enum i, Num i) => StackSet i a sid sd -> StackSet i a sid sd
+addWorkspace' s@(StackSet { current = scr@(Screen { workspace = w })
+ , hidden = ws })
+ = s { current = scr { workspace = Workspace newtag Nothing }
+ , hidden = w:ws }
+ where (newtag:_) = filter (not . (`tagMember` s)) [0..]
+
+removeWorkspace' :: StackSet i a sid sd -> StackSet i a sid sd
+removeWorkspace' s@(StackSet { current = scr@(Screen { workspace = Workspace { stack = Nothing } })
+ , hidden = (w:ws) })
+ = s { current = scr { workspace = w }
+ , hidden = ws }
+removeWorkspace' s = s