aboutsummaryrefslogtreecommitdiffstats
path: root/XMonad
diff options
context:
space:
mode:
authorlan3ny <lan3ny@gmail.com>2008-06-02 22:57:42 +0200
committerlan3ny <lan3ny@gmail.com>2008-06-02 22:57:42 +0200
commit02c5beadee33cd172248d7194ca6a2c1595a27b3 (patch)
tree01f787196a6c86192b6211865f0cc886edaf1856 /XMonad
parente9497d3506d3ff312fd92e6ff9ddf55367ca76ed (diff)
downloadXMonadContrib-02c5beadee33cd172248d7194ca6a2c1595a27b3.tar.gz
XMonadContrib-02c5beadee33cd172248d7194ca6a2c1595a27b3.tar.xz
XMonadContrib-02c5beadee33cd172248d7194ca6a2c1595a27b3.zip
XMonad.Actions.CopyWindow runOrCopy
darcs-hash:20080602205742-20747-65c3b7fcab114e84def368c54056a8f58cadec2e.gz
Diffstat (limited to 'XMonad')
-rw-r--r--XMonad/Actions/CopyWindow.hs30
1 files changed, 26 insertions, 4 deletions
diff --git a/XMonad/Actions/CopyWindow.hs b/XMonad/Actions/CopyWindow.hs
index 68d6e38..06d181e 100644
--- a/XMonad/Actions/CopyWindow.hs
+++ b/XMonad/Actions/CopyWindow.hs
@@ -2,7 +2,7 @@
-----------------------------------------------------------------------------
-- |
-- Module : XMonad.Actions.CopyWindow
--- Copyright : (c) David Roundy <droundy@darcs.net>, Ivan Veselov <veselov@gmail.com>
+-- Copyright : (c) David Roundy <droundy@darcs.net>, Ivan Veselov <veselov@gmail.com>, Lanny Ripple <lan3ny@gmail.com>
-- License : BSD3-style (see LICENSE)
--
-- Maintainer : ???
@@ -17,10 +17,12 @@
module XMonad.Actions.CopyWindow (
-- * Usage
-- $usage
- copy, copyToAll, copyWindow, killAllOtherCopies, kill1
+ copy, copyToAll, copyWindow, runOrCopy
+ , killAllOtherCopies, kill1
) where
import Prelude hiding (filter)
+import Control.Monad (filterM)
import qualified Data.List as L
import XMonad hiding (modify, workspaces)
import XMonad.StackSet
@@ -50,6 +52,11 @@ import XMonad.StackSet
--
-- > , ((modMask x .|. shiftMask, xK_c ), kill1) -- @@ Close the focused window
--
+-- Instead of copying a window from a workset to a workset maybe you don't
+-- want to have to remember where you placed it. For that consider:
+--
+-- > , ((modMask x, xK_b ), runOrCopy "firefox" (className =? "Firefox")) -- @@ run or copy firefox
+--
-- Another possibility which this extension provides is 'making window
-- always visible' (i.e. always on current workspace), similar to corresponding
-- metacity functionality. This behaviour is emulated through copying given
@@ -58,13 +65,13 @@ import XMonad.StackSet
--
-- Here is the example of keybindings which provide these actions:
--
--- > , ((modMask x, xK_v )", windows copyToAll) -- @@ Make focused window always visible
+-- > , ((modMask x, xK_v ), windows copyToAll) -- @@ Make focused window always visible
-- > , ((modMask x .|. shiftMask, xK_v ), killAllOtherCopies) -- @@ Toggle window state back
--
-- For detailed instructions on editing your key bindings, see
-- "XMonad.Doc.Extending#Editing_key_bindings".
--- | copy. Copy the focussed window to a new workspace.
+-- | copy. Copy the focused window to a new workspace.
copy :: (Eq s, Eq i, Eq a) => i -> StackSet i l a s sd -> StackSet i l a s sd
copy n s | Just w <- peek s = copyWindow w n s
| otherwise = s
@@ -85,6 +92,21 @@ copyWindow w n = copy'
else Just $ Stack a (L.delete a l) (L.delete a (t:r))) s
+-- | runOrCopy . runOrCopy will run the provided shell command unless it can
+-- find a specified window in which case it will copy the window to
+-- the current workspace. Similar to (i.e., stolen from) "XMonad.Actions.WindowGo".
+runOrCopy :: String -> Query Bool -> X ()
+runOrCopy action = copyMaybe $ spawn action
+
+-- | copyMaybe. Flatters "XMonad.Actions.WindowGo" ('raiseMaybe')
+copyMaybe :: X () -> Query Bool -> X ()
+copyMaybe f thatUserQuery = withWindowSet $ \s -> do
+ maybeResult <- filterM (runQuery thatUserQuery) (allWindows s)
+ case maybeResult of
+ [] -> f
+ (x:_) -> windows $ copyWindow x (currentTag s)
+
+
-- | Remove the focused window from this workspace. If it's present in no
-- other workspace, then kill it instead. If we do kill it, we'll get a
-- delete notify back from X.