aboutsummaryrefslogtreecommitdiffstats
path: root/XMonad/Prompt/XMonad.hs
blob: 5effbe479202a7724e1a24c1b30c833e7eab7ec4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
-----------------------------------------------------------------------------
-- |
-- 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
                              ) where

import XMonad
import XMonad.Prompt
import XMonad.Actions.Commands (defaultCommands, runCommand')

-- $usage
--
-- in Config.hs add:
--
-- > import XMonad.Prompt
-- > import XMonad.Prompt.XMonad
--
-- in you keybindings add:
--
-- >   , ((modMask .|. controlMask, xK_x), xmonadPrompt defaultXPConfig)
--

-- %import XMonad.Prompt
-- %import XMonad.Prompt.XMonad
-- %keybind , ((modMask .|. controlMask, xK_x), xmonadPrompt defaultXPConfig)

data XMonad = XMonad

instance XPrompt XMonad where
    showXPrompt XMonad = "XMonad: "

xmonadPrompt :: XPConfig -> X ()
xmonadPrompt c = do
    cmds <- defaultCommands
    mkXPrompt XMonad c (mkComplFunFromList (map fst cmds)) runCommand'

-- xmonad prompt with custom command list
xmonadPromptC :: [(String, X ())] -> XPConfig -> X ()
xmonadPromptC commands c = mkXPrompt XMonad c (mkComplFunFromList (map fst commands)) runCommand'