diff --git a/CHANGES.md b/CHANGES.md index 47d93b8449..10744a74e3 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -464,8 +464,8 @@ * `XMonad.Actions.WorkspaceNames` - - Added `workspaceNamesListTransform` which makes workspace names visible - to external pagers. + - Added `workspaceNamesRenameWS` which makes workspace names visible + to external pagers and tools like `wmctrl` or `arbtt`. * `XMonad.Util.PureX` diff --git a/XMonad/Actions/WorkspaceNames.hs b/XMonad/Actions/WorkspaceNames.hs index e8d935811d..a307f5662b 100644 --- a/XMonad/Actions/WorkspaceNames.hs +++ b/XMonad/Actions/WorkspaceNames.hs @@ -40,7 +40,7 @@ module XMonad.Actions.WorkspaceNames ( workspaceNamePrompt, -- * EwmhDesktops integration - workspaceNamesListTransform + workspaceNamesRenameWS, ) where import XMonad @@ -176,11 +176,11 @@ workspaceNamePrompt conf job = do contains completions input = return $ filter (isInfixOf input) completions --- | 'XMonad.Hooks.EwmhDesktops.workspaceListTransform' that exposes workspace +-- | 'XMonad.Hooks.EwmhDesktops.workspaceRename' that exposes workspace -- names to pagers and other EWMH-aware clients. -- -- Usage: --- > ewmh' def{ workspaceListTransform = workspaceNamesListTransform } -workspaceNamesListTransform :: X ([WindowSpace] -> [WindowSpace]) -workspaceNamesListTransform = - getWorkspaceNames ":" <&> \names -> map $ \ws -> ws{ W.tag = names (W.tag ws) ws } +-- > ewmh' def{ workspaceRename = workspaceNamesRenameWS } +workspaceNamesRenameWS :: X (WindowSpace -> WindowSpace) +workspaceNamesRenameWS = + getWorkspaceNames ":" <&> \names ws -> ws{ W.tag = names (W.tag ws) ws } diff --git a/XMonad/Hooks/EwmhDesktops.hs b/XMonad/Hooks/EwmhDesktops.hs index 6d0058a64a..48e2eda73a 100644 --- a/XMonad/Hooks/EwmhDesktops.hs +++ b/XMonad/Hooks/EwmhDesktops.hs @@ -72,14 +72,16 @@ import XMonad.Util.WindowProperties (getProp32) -- | TODO data EwmhConfig = EwmhConfig - { workspaceListTransform :: X ([WindowSpace] -> [WindowSpace]) + { workspaceListSort :: X ([WindowSpace] -> [WindowSpace]) + , workspaceRename :: X (WindowSpace -> WindowSpace) , activateHook :: ManageHook , fullscreen :: Bool } instance Default EwmhConfig where def = EwmhConfig - { workspaceListTransform = pure id + { workspaceListSort = pure id + , workspaceRename = pure id , activateHook = doFocus , fullscreen = False } @@ -166,16 +168,18 @@ ewmhDesktopsLogHook = ewmhDesktopsLogHook' def -- user-specified function to transform the workspace list (post-sorting) {-# DEPRECATED ewmhDesktopsLogHookCustom "Use ewmhDesktopsLogHook' instead" #-} ewmhDesktopsLogHookCustom :: ([WindowSpace] -> [WindowSpace]) -> X () -ewmhDesktopsLogHookCustom f = ewmhDesktopsLogHook' def{ workspaceListTransform = pure f } +ewmhDesktopsLogHookCustom f = ewmhDesktopsLogHook' def{ workspaceListSort = pure f } -- | -- Notifies pagers and window lists, such as those in the gnome-panel -- of the current state of workspaces and windows. ewmhDesktopsLogHook' :: EwmhConfig -> X () -ewmhDesktopsLogHook' EwmhConfig{workspaceListTransform} = withWindowSet $ \s -> do +ewmhDesktopsLogHook' EwmhConfig{workspaceListSort, workspaceRename} = withWindowSet $ \s -> do sort' <- getSortByIndex - workspaceListTransform' <- workspaceListTransform - let ws = workspaceListTransform' $ sort' $ W.workspaces s + workspaceListSort' <- workspaceListSort + workspaceRename' <- workspaceRename + let wsTransform = map workspaceRename' . workspaceListSort' + let ws = wsTransform $ sort' $ W.workspaces s -- Set number of workspaces and names thereof let desktopNames = map W.tag ws @@ -187,8 +191,8 @@ ewmhDesktopsLogHook' EwmhConfig{workspaceListTransform} = withWindowSet $ \s -> let clientList = nub . concatMap (maybe [] (\(W.Stack x l r) -> reverse l ++ r ++ [x]) . W.stack) $ ws whenChanged (ClientList clientList) $ setClientList clientList - -- Remap the current workspace to handle any renames that f might be doing. - let maybeCurrent' = W.tag <$> listToMaybe (workspaceListTransform' [W.workspace $ W.current s]) + -- Remap the current workspace to handle any renames that wsTransform might be doing. + let maybeCurrent' = W.tag <$> listToMaybe (wsTransform [W.workspace $ W.current s]) current = join (flip elemIndex (map W.tag ws) <$> maybeCurrent') whenChanged (CurrentDesktop $ fromMaybe 0 current) $ mapM_ setCurrentDesktop current @@ -213,7 +217,7 @@ ewmhDesktopsEventHook = ewmhDesktopsEventHook' def -- user-specified function to transform the workspace list (post-sorting) {-# DEPRECATED ewmhDesktopsEventHookCustom "Use ewmhDesktopsEventHook' instead" #-} ewmhDesktopsEventHookCustom :: ([WindowSpace] -> [WindowSpace]) -> Event -> X All -ewmhDesktopsEventHookCustom f = ewmhDesktopsEventHook' def{ workspaceListTransform = pure f } +ewmhDesktopsEventHookCustom f = ewmhDesktopsEventHook' def{ workspaceListSort = pure f } -- | -- Intercepts messages from pagers and similar applications and reacts on them. @@ -231,12 +235,12 @@ ewmhDesktopsEventHookCustom f = ewmhDesktopsEventHook' def{ workspaceListTransfo -- handled by other modules like "XMonad.Hooks.ManageHelpers", -- "XMonad.Actions.Minimize", etc.) ewmhDesktopsEventHook' :: EwmhConfig -> Event -> X All -ewmhDesktopsEventHook' EwmhConfig{ workspaceListTransform, activateHook, fullscreen } +ewmhDesktopsEventHook' EwmhConfig{ workspaceListSort, activateHook, fullscreen } e@ClientMessageEvent{ev_window = w, ev_message_type = mt, ev_data = d} = withWindowSet $ \s -> do sort' <- getSortByIndex - workspaceListTransform' <- workspaceListTransform - let ws = workspaceListTransform' $ sort' $ W.workspaces s + workspaceListSort' <- workspaceListSort + let ws = workspaceListSort' $ sort' $ W.workspaces s a_cd <- getAtom "_NET_CURRENT_DESKTOP" a_d <- getAtom "_NET_WM_DESKTOP"