module XMonad.Prompt.XMonad (
xmonadPrompt,
xmonadPromptC,
xmonadPromptCT,
XMonad,
) where
import XMonad
import XMonad.Prompt
import XMonad.Actions.Commands (defaultCommands)
import XMonad.Prelude (fromMaybe)
newtype XMonad = XMonad String
instance XPrompt XMonad where
showXPrompt :: XMonad -> String
showXPrompt (XMonad String
str) = String
str String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
": "
xmonadPrompt :: XPConfig -> X ()
xmonadPrompt :: XPConfig -> X ()
xmonadPrompt XPConfig
c = do
[(String, X ())]
cmds <- X [(String, X ())]
defaultCommands
[(String, X ())] -> XPConfig -> X ()
xmonadPromptC [(String, X ())]
cmds XPConfig
c
xmonadPromptC :: [(String, X ())] -> XPConfig -> X ()
xmonadPromptC :: [(String, X ())] -> XPConfig -> X ()
xmonadPromptC = String -> [(String, X ())] -> XPConfig -> X ()
xmonadPromptCT String
"XMonad"
xmonadPromptCT :: String -> [(String, X ())] -> XPConfig -> X ()
xmonadPromptCT :: String -> [(String, X ())] -> XPConfig -> X ()
xmonadPromptCT String
title' [(String, X ())]
commands XPConfig
c =
XMonad -> XPConfig -> ComplFunction -> (String -> X ()) -> X ()
forall p.
XPrompt p =>
p -> XPConfig -> ComplFunction -> (String -> X ()) -> X ()
mkXPrompt (String -> XMonad
XMonad String
title') XPConfig
c (XPConfig -> [String] -> ComplFunction
mkComplFunFromList' XPConfig
c (((String, X ()) -> String) -> [(String, X ())] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map (String, X ()) -> String
forall a b. (a, b) -> a
fst [(String, X ())]
commands)) ((String -> X ()) -> X ()) -> (String -> X ()) -> X ()
forall a b. (a -> b) -> a -> b
$
X () -> Maybe (X ()) -> X ()
forall a. a -> Maybe a -> a
fromMaybe (() -> X ()
forall a. a -> X a
forall (m :: * -> *) a. Monad m => a -> m a
return ()) (Maybe (X ()) -> X ())
-> (String -> Maybe (X ())) -> String -> X ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String -> [(String, X ())] -> Maybe (X ())
forall a b. Eq a => a -> [(a, b)] -> Maybe b
`lookup` [(String, X ())]
commands)