From 612619d57711601d13c9d65fa7077c281c6c09f1 Mon Sep 17 00:00:00 2001 From: Brent Yorgey Date: Tue, 27 Jan 2009 23:23:55 +0100 Subject: move XMonad.Actions.SinkAll functionality to more general XMonad.Actions.WithAll, and re-export sinkAll from X.A.SinkAll for backwards compatibility darcs-hash:20090127222355-1e371-a7beafc93e557a5c5af0a4b224ac0f55f1e37a18.gz --- XMonad/Actions/WithAll.hs | 54 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 XMonad/Actions/WithAll.hs (limited to 'XMonad/Actions/WithAll.hs') diff --git a/XMonad/Actions/WithAll.hs b/XMonad/Actions/WithAll.hs new file mode 100644 index 0000000..f882644 --- /dev/null +++ b/XMonad/Actions/WithAll.hs @@ -0,0 +1,54 @@ +----------------------------------------------------------------------------- +-- | +-- Module : XMonad.Actions.WithAll +-- License : BSD3-style (see LICENSE) +-- Stability : unstable +-- Portability : unportable +-- +-- Provides functions for performing a given action on all windows of +-- the current workspace. +----------------------------------------------------------------------------- + +module XMonad.Actions.WithAll ( + -- * Usage + -- $usage + sinkAll, withAll, + withAll', killAll) where + +import Data.Foldable hiding (foldr) + +import XMonad +import XMonad.Core +import XMonad.Operations +import XMonad.StackSet + +-- $usage +-- +-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@: +-- +-- > import XMonad.Actions.WithAll +-- +-- then add a keybinding; for example: +-- +-- , ((modMask x .|. shiftMask, xK_t), sinkAll) +-- +-- For detailed instructions on editing your key bindings, see +-- "XMonad.Doc.Extending#Editing_key_bindings". + +-- | Un-float all floating windows on the current workspace. +sinkAll :: X () +sinkAll = withAll' sink + +-- | Apply a function to all windows on the current workspace. +withAll' :: (Window -> WindowSet -> WindowSet) -> X () +withAll' f = windows $ \ws -> let all' = integrate' . stack . workspace . current $ ws + in foldr f ws all' + +-- | Execute an 'X' action for each window on the current workspace. +withAll :: (Window -> X ()) -> X() +withAll f = withWindowSet $ \ws -> let all' = integrate' . stack . workspace . current $ ws + in forM_ all' f + +-- | Kill all the windows on the current workspace. +killAll :: X() +killAll = withAll killWindow \ No newline at end of file -- cgit v1.2.3