X.P.XMonad: Add xmonadPromptCT

Currently when creating an XMonad Prompt one is stuck with "XMonad:" as
the title for the prompt.  However, sometimes it is nice to be able to
create a prompt with custom commands that has a particular title.

This changes the internals of X.P.XMonad to facilitate this and adds
xmonadPromptCT as a user facing function.
This commit is contained in:
Solomon Bothwell
2021-09-07 21:20:58 -07:00
committed by slotThe
parent 81339f2044
commit b79fbf6975
2 changed files with 14 additions and 4 deletions

View File

@@ -17,6 +17,7 @@ module XMonad.Prompt.XMonad (
-- $usage
xmonadPrompt,
xmonadPromptC,
xmonadPromptCT,
XMonad,
) where
@@ -38,10 +39,10 @@ import XMonad.Prelude (fromMaybe)
-- For detailed instruction on editing the key binding see
-- "XMonad.Doc.Extending#Editing_key_bindings".
data XMonad = XMonad
newtype XMonad = XMonad String
instance XPrompt XMonad where
showXPrompt XMonad = "XMonad: "
showXPrompt (XMonad str) = str <> ": "
xmonadPrompt :: XPConfig -> X ()
xmonadPrompt c = do
@@ -50,6 +51,10 @@ xmonadPrompt c = do
-- | An xmonad prompt with a custom command list
xmonadPromptC :: [(String, X ())] -> XPConfig -> X ()
xmonadPromptC commands c =
mkXPrompt XMonad c (mkComplFunFromList' c (map fst commands)) $
xmonadPromptC = xmonadPromptCT "XMonad"
-- | An xmonad prompt with a custom command list and a custom title
xmonadPromptCT :: String -> [(String, X ())] -> XPConfig -> X ()
xmonadPromptCT title' commands c =
mkXPrompt (XMonad title') c (mkComplFunFromList' c (map fst commands)) $
fromMaybe (return ()) . (`lookup` commands)