New patches: [XMonadContrib.FindEmptyWorkspace Miikka Koskinen **20070513184338 With this module you can find empty workspaces, view them and tag windows to them. ] { addfile ./FindEmptyWorkspace.hs hunk ./FindEmptyWorkspace.hs 1 +----------------------------------------------------------------------------- +-- | +-- Module : XMonadContrib.FindEmptyWorkspace +-- Copyright : (c) Miikka Koskinen 2007 +-- License : BSD3-style (see LICENSE) +-- +-- Maintainer : arcatan@kapsi.fi +-- +----------------------------------------------------------------------------- +-- +-- Find an empty workspace in xmonad. +-- +-- To use, modify your Config.hs to: +-- +-- import XMonadContrib.FindEmptyWorkspace +-- +-- and add a keybinding: +-- +-- , ((modMask, xK_m ), viewEmptyWorkspace) +-- , ((modMask .|. shiftMask, xK_m ), tagToEmptyWorkspace) +-- +-- Now you can jump to an empty workspace with mod-n. Mod-shift-n will +-- tag the current window to an empty workspace and view it. +-- + +module XMonadContrib.FindEmptyWorkspace ( + viewEmptyWorkspace, tagToEmptyWorkspace + ) where + +import Control.Monad.State +import qualified Data.Map as M + +import XMonad +import Operations +import qualified StackSet as W + +-- | Find the first empty workspace in a WindowSet. Returns Nothing if +-- all workspaces are in use. +findEmptyWorkspace :: WindowSet -> Maybe WorkspaceId +findEmptyWorkspace = findKey (([],[]) ==) . W.stacks + +withEmptyWorkspace :: (WorkspaceId -> X ()) -> X () +withEmptyWorkspace f = do + ws <- gets workspace + whenJust (findEmptyWorkspace ws) f + +-- | Find and view an empty workspace. Do nothing if all workspaces are +-- in use. +viewEmptyWorkspace :: X () +viewEmptyWorkspace = withEmptyWorkspace view + +-- | Tag current window to an empty workspace and view it. Do nothing if +-- all workspaces are in use. +tagToEmptyWorkspace :: X () +tagToEmptyWorkspace = withEmptyWorkspace $ \w -> tag w >> view w + +-- Thanks to mauke on #haskell +findKey :: (a -> Bool) -> M.Map k a -> Maybe k +findKey f = M.foldWithKey (\k a -> mplus (if f a then Just k else Nothing)) Nothing } Context: [make rotView only consider non-visible workspaces (Xinerama) Jason Creighton **20070510012059] [fix commend in RotView. David Roundy **20070505185654] [switch to Message type for layout messages Don Stewart **20070505014332] [Fix instructions in Mosaic. Chris Mears **20070503222345] [add Mosaic layout. David Roundy **20070503151024] [-Wall police Spencer Janssen **20070503211700] [Make RotView build, and add a brief description. Chris Mears **20070503104234] [comment: Gave URL to xinerama-enabled dmenu patch Jason Creighton **20070503053133] [Put dmenu in X too Spencer Janssen **20070503053727] [Add dmenu (thanks jcreigh) Spencer Janssen **20070503052225] [add RotView module. David Roundy **20070421233838] [XMonadContrib.DwmPromote: dwm-like promote Miikka Koskinen **20070501082031 I like the way dwm's equivalent to xmonad's promote works, so I implemented dwmpromote. ] [add simple date example Don Stewart **20070429064013] [more details Don Stewart **20070429061426] [add readme Don Stewart **20070429061329] [Initial import of xmonad contributions Don Stewart **20070429061150] Patch bundle hash: 54475666b60ed44d4b74700a08fc1311626d1294