Merge pull request #534 from oogeek/X.A.CopyWindow-doc-improve

X.A.CopyWindow: Add copiesPP
This commit is contained in:
slotThe 2021-06-10 14:08:27 +02:00 committed by GitHub
commit 6d184e859c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 12 deletions

View File

@ -625,6 +625,11 @@
- Added new aliases `PhysicalWindowSpace` and `VirtualWindowSpace` - Added new aliases `PhysicalWindowSpace` and `VirtualWindowSpace`
for a `WindowSpace` for easier to read function signatures. for a `WindowSpace` for easier to read function signatures.
* `XMonad.Actions.CopyWindow`
- Added `copiesPP` to make a `PP` aware of copies of the focused
window.
## 0.16 ## 0.16
### Breaking Changes ### Breaking Changes

View File

@ -21,7 +21,7 @@ module XMonad.Actions.CopyWindow (
, killAllOtherCopies, kill1, taggedWindows, copiesOfOn , killAllOtherCopies, kill1, taggedWindows, copiesOfOn
-- * Highlight workspaces containing copies in logHook -- * Highlight workspaces containing copies in logHook
-- $logHook -- $logHook
, wsContainingCopies , wsContainingCopies, copiesPP
) where ) where
import XMonad import XMonad
@ -29,6 +29,7 @@ import Control.Arrow ((&&&))
import qualified Data.List as L import qualified Data.List as L
import XMonad.Actions.WindowGo import XMonad.Actions.WindowGo
import XMonad.Hooks.StatusBar.PP (PP(..))
import qualified XMonad.StackSet as W import qualified XMonad.StackSet as W
-- $usage -- $usage
@ -76,18 +77,24 @@ import qualified XMonad.StackSet as W
-- "XMonad.Doc.Extending#Editing_key_bindings". -- "XMonad.Doc.Extending#Editing_key_bindings".
-- $logHook -- $logHook
-- To distinguish workspaces containing copies of the focused window use
-- something like:
-- --
-- > sampleLogHook h = do -- To distinguish workspaces containing copies of the focused window, use 'copiesPP'.
-- > copies <- wsContainingCopies -- 'copiesPP' takes a pretty printer and makes it aware of copies of the focused window.
-- > let check ws | ws `elem` copies = pad . xmobarColor "red" "black" $ ws -- It can be applied when creating a 'XMonad.Hooks.StatusBar.StatusBarConfig'.
-- > | otherwise = pad ws --
-- > dynamicLogWithPP myPP {ppHidden = check, ppOutput = hPutStrLn h} -- A sample config looks like this:
-- > --
-- > main = do -- > mySB = statusBarProp "xmobar" (copiesPP (pad . xmobarColor "red" "black") xmobarPP)
-- > h <- spawnPipe "xmobar" -- > main = xmonad $ withEasySB mySB defToggleStrutsKey def
-- > xmonad def { logHook = sampleLogHook h }
-- | Take a pretty printer and make it aware of copies by using the provided function
-- to show hidden workspaces that contain copies of the focused window.
copiesPP :: (WorkspaceId -> String) -> PP -> X PP
copiesPP wtoS pp = do
copies <- wsContainingCopies
let check ws | ws `elem` copies = wtoS ws
| otherwise = ppHidden pp ws
return pp { ppHidden = check }
-- | Copy the focused window to a workspace. -- | Copy the focused window to a workspace.
copy :: (Eq s, Eq i, Eq a) => i -> W.StackSet i l a s sd -> W.StackSet i l a s sd copy :: (Eq s, Eq i, Eq a) => i -> W.StackSet i l a s sd -> W.StackSet i l a s sd