mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 11:30:22 -07:00
XMonad.Actions.WorkspaceName.workspaceNamePrompt is XMonad.Prompt.Workspace.workspacePrompt acting on the workspace name.
This commit is contained in:
parent
c4b3895af6
commit
bbf36809e9
@ -32,6 +32,9 @@ module XMonad.Actions.WorkspaceNames (
|
|||||||
swapTo,
|
swapTo,
|
||||||
swapTo',
|
swapTo',
|
||||||
swapWithCurrent,
|
swapWithCurrent,
|
||||||
|
|
||||||
|
-- * Workspace prompt
|
||||||
|
workspaceNamePrompt
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import XMonad
|
import XMonad
|
||||||
@ -47,6 +50,7 @@ import XMonad.Util.WorkspaceCompare (getSortByIndex)
|
|||||||
|
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
import Data.Maybe (fromMaybe)
|
import Data.Maybe (fromMaybe)
|
||||||
|
import Data.List (isInfixOf)
|
||||||
|
|
||||||
-- $usage
|
-- $usage
|
||||||
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@ file:
|
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@ file:
|
||||||
@ -150,3 +154,18 @@ swapNames w1 w2 = do
|
|||||||
let getname w = fromMaybe "" $ M.lookup w m
|
let getname w = fromMaybe "" $ M.lookup w m
|
||||||
set w name m' = if null name then M.delete w m' else M.insert w name m'
|
set w name m' = if null name then M.delete w m' else M.insert w name m'
|
||||||
XS.put $ WorkspaceNames $ set w1 (getname w2) $ set w2 (getname w1) $ m
|
XS.put $ WorkspaceNames $ set w1 (getname w2) $ set w2 (getname w1) $ m
|
||||||
|
|
||||||
|
-- | Same behavior than 'XMonad.Prompt.Workspace.workspacePrompt' excepted it acts on the workspace name provided by this module.
|
||||||
|
workspaceNamePrompt :: XPConfig -> (String -> X ()) -> X ()
|
||||||
|
workspaceNamePrompt conf job = do
|
||||||
|
myWorkspaces <- gets $ map W.tag . W.workspaces . windowset
|
||||||
|
myWorkspacesName <- getWorkspaceNames >>= \f -> return $ map f myWorkspaces
|
||||||
|
let pairs = zip myWorkspacesName myWorkspaces
|
||||||
|
mkXPrompt (Wor "Select workspace: ") conf
|
||||||
|
(contains myWorkspacesName)
|
||||||
|
(job . toWsId pairs)
|
||||||
|
where toWsId pairs name = case lookup name pairs of
|
||||||
|
Nothing -> ""
|
||||||
|
Just i -> i
|
||||||
|
contains completions input =
|
||||||
|
return $ filter (Data.List.isInfixOf input) completions
|
||||||
|
Loading…
x
Reference in New Issue
Block a user