diff --git a/CHANGES.md b/CHANGES.md index 1e17f500c6..6dfed98126 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -542,8 +542,8 @@ * `XMonad.Actions.WorkspaceNames` - - Added `workspaceNamesListTransform` which makes workspace names visible - to external pagers. + - Added `workspaceNamesEwmh` which makes workspace names visible to + external pagers. * `XMonad.Util.PureX` diff --git a/XMonad/Actions/WorkspaceNames.hs b/XMonad/Actions/WorkspaceNames.hs index 1e877ec053..04abb44c77 100644 --- a/XMonad/Actions/WorkspaceNames.hs +++ b/XMonad/Actions/WorkspaceNames.hs @@ -22,7 +22,6 @@ module XMonad.Actions.WorkspaceNames ( -- * Workspace naming renameWorkspace, - workspaceNamesPP, getWorkspaceNames', getWorkspaceNames, getWorkspaceName, @@ -38,8 +37,9 @@ module XMonad.Actions.WorkspaceNames ( -- * Workspace prompt workspaceNamePrompt, - -- * EwmhDesktops integration - workspaceNamesListTransform + -- * StatusBar, EwmhDesktops integration + workspaceNamesPP, + workspaceNamesEwmh, ) where import XMonad @@ -50,6 +50,7 @@ import qualified XMonad.Util.ExtensibleState as XS import XMonad.Actions.CycleWS (findWorkspace, WSType(..), Direction1D(..), anyWS) import qualified XMonad.Actions.SwapWorkspaces as Swap import XMonad.Hooks.DynamicLog (PP(..)) +import XMonad.Hooks.EwmhDesktops (addEwmhWorkspaceRename) import XMonad.Prompt (mkXPrompt, XPConfig) import XMonad.Prompt.Workspace (Wor(Wor)) import XMonad.Util.WorkspaceCompare (getSortByIndex) @@ -70,6 +71,10 @@ import qualified Data.Map as M -- > myLogHook = -- > workspaceNamesPP xmobarPP >>= dynamicLogString >>= xmonadPropLog -- +-- and integrate with "XMonad.Hooks.EwmhDesktops": +-- +-- > main = xmonad $ … . workspaceNamesEwmh . ewmh . … $ def{…} +-- -- We also provide a modification of "XMonad.Actions.SwapWorkspaces"\'s -- functionality, which may be used this way: -- @@ -133,11 +138,6 @@ renameWorkspace conf = mkXPrompt pr conf (const (return [])) setCurrentWorkspaceName where pr = Wor "Workspace name: " --- | Modify "XMonad.Hooks.DynamicLog"\'s pretty-printing format to show --- workspace names as well. -workspaceNamesPP :: PP -> X PP -workspaceNamesPP pp = getWorkspaceNames ":" <&> \ren -> pp{ ppRename = ppRename pp >=> ren } - -- | See 'XMonad.Actions.SwapWorkspaces.swapTo'. This is the same with names. swapTo :: Direction1D -> X () swapTo dir = swapTo' dir anyWS @@ -175,12 +175,12 @@ workspaceNamePrompt conf job = do contains completions input = return $ filter (isInfixOf input) completions --- | Workspace list transformation for --- 'XMonad.Hooks.EwmhDesktops.ewmhDesktopsLogHookCustom' that exposes --- workspace names to pagers and other EWMH-aware clients. --- --- Usage: --- > logHook = (workspaceNamesListTransform >>= ewmhDesktopsLogHookCustom) <+> … -workspaceNamesListTransform :: X ([WindowSpace] -> [WindowSpace]) -workspaceNamesListTransform = - getWorkspaceNames ":" <&> \names -> map $ \ws -> ws{ W.tag = names (W.tag ws) ws } +-- | Modify "XMonad.Hooks.DynamicLog"\'s pretty-printing format to show +-- workspace names as well. +workspaceNamesPP :: PP -> X PP +workspaceNamesPP pp = getWorkspaceNames ":" <&> \ren -> pp{ ppRename = ppRename pp >=> ren } + +-- | Tell "XMonad.Hooks.EwmhDesktops" to append workspace names to desktop +-- names. +workspaceNamesEwmh :: XConfig l -> XConfig l +workspaceNamesEwmh = addEwmhWorkspaceRename $ getWorkspaceNames ":"