Tony Zorman b1b3c4c469 ~/.xmonad/xmonad.hs -> xmonad.hs
With XDG support so firmly ingrained now, it's about time we stop
hard-coding the configuration path in the docs.
2023-12-22 18:17:17 +01:00

62 lines
1.9 KiB
Haskell

-----------------------------------------------------------------------------
-- |
-- Module : XMonad.Prompt.XMonad
-- Description : A prompt for running XMonad commands.
-- 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,
xmonadPromptCT,
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.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
-- <https://xmonad.org/TUTORIAL.html#customizing-xmonad the tutorial>.
newtype XMonad = XMonad String
instance XPrompt XMonad where
showXPrompt (XMonad str) = str <> ": "
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 = 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)