From 5f36dbbca79945674f4112e6f729f7a1360595e5 Mon Sep 17 00:00:00 2001 From: Brent Yorgey Date: Wed, 28 Nov 2007 15:24:17 +0100 Subject: refactor XMonad.Prompt, add new modules XMonad.Prompt.{Input,Email} XMonad.Prompt.Input is a new module which provides a framework for prompting the user for input and passing it along to some other action, useful for building actions which require user input. XMonad.Prompt.Email is a simple example of the use of XMonad.Prompt.Input, which prompts the user for a recipient, subject, and body, and sends a one-line email. I also made a small refactoring to XMonad.Prompt in order to support XMonad.Prompt.Input. darcs-hash:20071128142417-bd4d7-659505bd53d074cd3d11df65014a722b6275d57c.gz --- XMonad/Prompt/Email.hs | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 XMonad/Prompt/Email.hs (limited to 'XMonad/Prompt/Email.hs') diff --git a/XMonad/Prompt/Email.hs b/XMonad/Prompt/Email.hs new file mode 100644 index 0000000..7468c9f --- /dev/null +++ b/XMonad/Prompt/Email.hs @@ -0,0 +1,63 @@ +----------------------------------------------------------------------------- +-- | +-- Module : XMonad.Prompt.Email +-- Copyright : (c) 2007 Brent Yorgey +-- License : BSD-style (see LICENSE) +-- +-- Maintainer : +-- Stability : unstable +-- Portability : unportable +-- +-- A prompt for sending quick, one-line emails, via the standard GNU +-- \'mail\' utility (which must be in your $PATH). This module is +-- intended mostly as an example of using "XMonad.Prompt.Input" to +-- build an action requiring user input. +-- +----------------------------------------------------------------------------- + +module XMonad.Prompt.Email ( + -- * Usage + -- $usage + emailPrompt + ) where + +import XMonad.Core +import XMonad.Util.Run +import XMonad.Prompt +import XMonad.Prompt.Input + +-- $usage +-- +-- You can use this module by importing it, along with +-- "XMonad.Prompt", into your ~\/.xmonad\/xmonad.hs file: +-- +-- > import XMonad.Prompt +-- > import XMonad.Prompt.Email +-- +-- and adding an appropriate keybinding, for example: +-- +-- > , ((modMask x .|. controlMask, xK_e), emailPrompt defaultXPConfig addresses) +-- +-- where @addresses@ is a list of email addresses that should +-- autocomplete, for example: +-- +-- > addresses = ["me@me.com", "mr@big.com", "tom.jones@foo.bar"] +-- +-- You can still send email to any address, but sending to these +-- addresses will be faster since you only have to type a few +-- characters and then hit \'tab\'. +-- +-- For detailed instructions on editing your key bindings, see +-- "XMonad.Doc.Extending#Editing_key_bindings". + + +-- | Prompt the user for a recipient, subject, and body, and send an +-- email via the GNU \'mail\' utility. The second argument is a list +-- of addresses for autocompletion. +emailPrompt :: XPConfig -> [String] -> X () +emailPrompt c addrs = + inputPromptWithCompl c "To" (mkComplFunFromList addrs) ?+ \to -> + inputPrompt c "Subject" ?+ \subj -> + inputPrompt c "Body" ?+ \body -> + io $ runProcessWithInput "mail" ["-s", subj, to] (body ++ "\n") + >> return () -- cgit v1.2.3