mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 03:20:21 -07:00
X.A.CopyWindow: Add copiesPP
This is a function that takes a pretty-printer and makes it aware of copies of the currently focused window. This is particularly nice when using it with a StatusBarConfig. Related: https://github.com/xmonad/xmonad-contrib/pull/463
This commit is contained in:
parent
c89730fc32
commit
d521d18dde
@ -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
|
||||||
|
@ -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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user