Files
xmonad-contrib/XMonad/Prompt/XMonad.hs
slotThe 2469269119 New module: XMonad.Prelude
This is a convenience module in order to have less import noise.  It
re-exports the following:

  a) Commonly used modules in full (Data.Foldable, Data.Applicative, and
     so on); though only those that play nicely with each other, so that
     XMonad.Prelude can be imported unqualified without any problems.
     This prevents things like `Prelude.(.)` and `Control.Category.(.)`
     fighting with each other.

  b) Helper functions that don't necessarily fit in any other module;
     e.g., the often used abbreviation `fi = fromIntegral`.
2021-05-13 17:44:47 +02:00

56 lines
1.6 KiB
Haskell

-----------------------------------------------------------------------------
-- |
-- Module : XMonad.Prompt.XMonad
-- Copyright : (C) 2007 Andrea Rossato
-- License : BSD3
--
-- Maintainer : andrea.rossato@unibz.it
-- Stability : unstable
-- Portability : unportable
--
-- A prompt for running XMonad commands
--
-----------------------------------------------------------------------------
module XMonad.Prompt.XMonad (
-- * Usage
-- $usage
xmonadPrompt,
xmonadPromptC,
XMonad,
) where
import XMonad
import XMonad.Prompt
import XMonad.Actions.Commands (defaultCommands)
import XMonad.Prelude (fromMaybe)
-- $usage
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@:
--
-- > import XMonad.Prompt
-- > import XMonad.Prompt.XMonad
--
-- in your keybindings add:
--
-- > , ((modm .|. controlMask, xK_x), xmonadPrompt def)
--
-- For detailed instruction on editing the key binding see
-- "XMonad.Doc.Extending#Editing_key_bindings".
data XMonad = XMonad
instance XPrompt XMonad where
showXPrompt XMonad = "XMonad: "
xmonadPrompt :: XPConfig -> X ()
xmonadPrompt c = do
cmds <- defaultCommands
xmonadPromptC cmds c
-- | An xmonad prompt with a custom command list
xmonadPromptC :: [(String, X ())] -> XPConfig -> X ()
xmonadPromptC commands c =
mkXPrompt XMonad c (mkComplFunFromList' c (map fst commands)) $
fromMaybe (return ()) . (`lookup` commands)