aboutsummaryrefslogtreecommitdiffstats
path: root/XMonad
diff options
context:
space:
mode:
authorDaniel Wagner <daniel@wagner-home.com>2013-04-09 00:52:51 +0200
committerDaniel Wagner <daniel@wagner-home.com>2013-04-09 00:52:51 +0200
commit291fbb7d976057170d3be8092e8c219ed9ddee05 (patch)
tree0b899b70980f83a5c1935b4ff6e519d0a45a5e14 /XMonad
parentce8caa14c9ff7e18f89cab0897cd522004e736f2 (diff)
downloadXMonadContrib-291fbb7d976057170d3be8092e8c219ed9ddee05.tar.gz
XMonadContrib-291fbb7d976057170d3be8092e8c219ed9ddee05.tar.xz
XMonadContrib-291fbb7d976057170d3be8092e8c219ed9ddee05.zip
add whenCurrentOn to X.L.IndependentScreens
Ignore-this: ceea3d391f270abc9ed8e52ce19fb1ac darcs-hash:20130408225251-76d51-9000eed38173684de773c3bb70099020a8a3973c.gz
Diffstat (limited to 'XMonad')
-rw-r--r--XMonad/Layout/IndependentScreens.hs35
1 files changed, 35 insertions, 0 deletions
diff --git a/XMonad/Layout/IndependentScreens.hs b/XMonad/Layout/IndependentScreens.hs
index 5ff3873..5a38588 100644
--- a/XMonad/Layout/IndependentScreens.hs
+++ b/XMonad/Layout/IndependentScreens.hs
@@ -20,6 +20,7 @@ module XMonad.Layout.IndependentScreens (
workspaces',
withScreens, onCurrentScreen,
marshallPP,
+ whenCurrentOn,
countScreens,
-- * Converting between virtual and physical workspaces
-- $converting
@@ -140,6 +141,40 @@ marshallPP s pp = pp {
ppSort = fmap (marshallSort s) (ppSort pp)
}
+-- | Take a pretty-printer and turn it into one that only runs when the current
+-- workspace is one associated with the given screen. The way this works is a
+-- bit hacky, so beware: the 'ppOutput' field of the input will not be invoked
+-- if either of the following conditions is met:
+--
+-- 1. The 'ppSort' of the input returns an empty list (when not given one).
+-- 2. The 'ppOrder' of the input returns the exact string "\0".
+--
+-- For example, you can use this to create a pipe which tracks the title of the
+-- window currently focused on a given screen (even if the screen is not
+-- current) by doing something like this:
+--
+-- > ppFocus s = whenCurrentOn s defaultPP
+-- > { ppOrder = \(_:_:title:_) -> [title]
+-- > , ppOutput = appendFile ("focus" ++ show s) . (++ "\n")
+-- > }
+--
+-- Sequence a few of these pretty-printers to get a log hook that keeps each
+-- screen's title up-to-date.
+whenCurrentOn :: ScreenId -> PP -> PP
+whenCurrentOn s pp = pp
+ { ppSort = do
+ sort <- ppSort pp
+ return $ \xs -> case xs of
+ x:_ | unmarshallS (tag x) == s -> sort xs
+ _ -> []
+ , ppOrder = \i@(wss:rest) -> case wss of
+ "" -> ["\0"] -- we got passed no workspaces; this is the signal from ppSort that this is a boring case
+ _ -> ppOrder pp i
+ , ppOutput = \s -> case s of
+ "\0" -> return () -- we got passed the signal from ppOrder that this is a boring case
+ _ -> ppOutput pp s
+ }
+
marshallSort :: ScreenId -> ([WindowSpace] -> [WindowSpace]) -> ([WindowSpace] -> [WindowSpace])
marshallSort s vSort = pScreens . vSort . vScreens where
onScreen ws = unmarshallS (tag ws) == s