Skip to content

Commit

Permalink
X.A.WorkspaceNames: Adapt EwmhDesktops integration to the new interface
Browse files Browse the repository at this point in the history
Related: xmonad#105
Related: xmonad#122
Related: f271d59 ("X.A.WorkspaceNames: Provide workspaceListTransform for EwmhDesktops")
  • Loading branch information
liskin committed Oct 19, 2021
1 parent c1d4ca1 commit 860c5ac
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
4 changes: 2 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -545,8 +545,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`

Expand Down
35 changes: 18 additions & 17 deletions XMonad/Actions/WorkspaceNames.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ module XMonad.Actions.WorkspaceNames (

-- * Workspace naming
renameWorkspace,
workspaceNamesPP,
getWorkspaceNames',
getWorkspaceNames,
getWorkspaceName,
Expand All @@ -38,8 +37,9 @@ module XMonad.Actions.WorkspaceNames (
-- * Workspace prompt
workspaceNamePrompt,

-- * EwmhDesktops integration
workspaceNamesListTransform
-- * StatusBar, EwmhDesktops integration
workspaceNamesPP,
workspaceNamesEwmh,
) where

import XMonad
Expand All @@ -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.StatusBar.PP (PP(..))
import XMonad.Hooks.EwmhDesktops (addEwmhWorkspaceRename)
import XMonad.Prompt (mkXPrompt, XPConfig)
import XMonad.Prompt.Workspace (Wor(Wor))
import XMonad.Util.WorkspaceCompare (getSortByIndex)
Expand All @@ -72,6 +73,11 @@ import qualified Data.Map as M
-- Check "XMonad.Hooks.StatusBar" for more information on how to incorprate
-- this into your status bar.
--
-- To expose workspace names to pagers and other EWMH clients, integrate this
-- 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:
--
Expand Down Expand Up @@ -135,11 +141,6 @@ renameWorkspace conf =
mkXPrompt pr conf (const (return [])) setCurrentWorkspaceName
where pr = Wor "Workspace name: "

-- | Modify 'XMonad.Hooks.StatusBar.PP.PP'\'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
Expand Down Expand Up @@ -177,12 +178,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.StatusBar.PP.PP'\'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 ":"

0 comments on commit 860c5ac

Please sign in to comment.