Merge pull request #201 from xrvdg/commands-dmenulike

X.A.Commands: Parameterize runCommand to accept dmenu-like launchers.
This commit is contained in:
Brent Yorgey
2017-07-10 11:41:17 -04:00
committed by GitHub

View File

@@ -19,6 +19,7 @@ module XMonad.Actions.Commands (
-- $usage -- $usage
commandMap, commandMap,
runCommand, runCommand,
runCommandConfig,
runCommand', runCommand',
workspaceCommands, workspaceCommands,
screenCommands, screenCommands,
@@ -103,11 +104,18 @@ defaultCommands = do
] ]
-- | Given a list of command\/action pairs, prompt the user to choose a -- | Given a list of command\/action pairs, prompt the user to choose a
-- command and return the corresponding action. -- command using dmenu and return the corresponding action.
runCommand :: [(String, X ())] -> X () runCommand :: [(String, X ())] -> X ()
runCommand cl = do runCommand = runCommandConfig dmenu
-- | Given a list of command\/action pairs, prompt the user to choose a
-- command using dmenu-compatible launcher and return the corresponding action.
-- See X.U.Dmenu for compatible launchers.
runCommandConfig :: ([String] -> X String) -> [(String, X ())] -> X()
runCommandConfig f cl = do
let m = commandMap cl let m = commandMap cl
choice <- dmenu (M.keys m) choice <- f (M.keys m)
fromMaybe (return ()) (M.lookup choice m) fromMaybe (return ()) (M.lookup choice m)
-- | Given the name of a command from 'defaultCommands', return the -- | Given the name of a command from 'defaultCommands', return the