aboutsummaryrefslogtreecommitdiffstats
path: root/XMonad/Actions
diff options
context:
space:
mode:
authorAntoine Eiche <lewo@abesis.fr>2015-06-01 11:32:53 +0200
committerAntoine Eiche <lewo@abesis.fr>2015-06-01 11:32:53 +0200
commit6892ab9fecbe6c85b3c8e2c2c807cebbfca42c4e (patch)
tree260e053fd520915058af1600ed56787d1eb4a565 /XMonad/Actions
parent03478def082048412d5e65d72b313e16406a04ad (diff)
downloadXMonadContrib-6892ab9fecbe6c85b3c8e2c2c807cebbfca42c4e.tar.gz
XMonadContrib-6892ab9fecbe6c85b3c8e2c2c807cebbfca42c4e.tar.xz
XMonadContrib-6892ab9fecbe6c85b3c8e2c2c807cebbfca42c4e.zip
XMonad.Actions.WorkspaceName.workspaceNamePrompt is XMonad.Prompt.Workspace.workspacePrompt acting on the workspace name.
Ignore-this: 6a34c0ed8a8d78b90b915f93e0c34cd9 darcs-hash:20150601093253-9943a-cc0b0854c5b1e1d2501885a1a94c1a3c343722dc.gz
Diffstat (limited to 'XMonad/Actions')
-rw-r--r--XMonad/Actions/WorkspaceNames.hs19
1 files changed, 19 insertions, 0 deletions
diff --git a/XMonad/Actions/WorkspaceNames.hs b/XMonad/Actions/WorkspaceNames.hs
index 368e6e1..16661c0 100644
--- a/XMonad/Actions/WorkspaceNames.hs
+++ b/XMonad/Actions/WorkspaceNames.hs
@@ -32,6 +32,9 @@ module XMonad.Actions.WorkspaceNames (
swapTo,
swapTo',
swapWithCurrent,
+
+ -- * Workspace prompt
+ workspaceNamePrompt
) where
import XMonad
@@ -47,6 +50,7 @@ import XMonad.Util.WorkspaceCompare (getSortByIndex)
import qualified Data.Map as M
import Data.Maybe (fromMaybe)
+import Data.List (isInfixOf)
-- $usage
-- 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
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
+
+-- | 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