xmonad-contrib-0.17.1: Community-maintained extensions for xmonad
Copyright(c) 2007 Brent Yorgey
LicenseBSD-style (see LICENSE)
Maintainer<byorgey@gmail.com>
Stabilitystable
Portabilityunportable
Safe HaskellSafe-Inferred
LanguageHaskell2010

XMonad.Prompt.AppendFile

Contents

Description

A prompt for appending a single line of text to a file. Useful for keeping a file of notes, things to remember for later, and so on--- using a keybinding, you can write things down just about as quickly as you think of them, so it doesn't have to interrupt whatever else you're doing.

Who knows, it might be useful for other purposes as well!

Synopsis

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.AppendFile

and adding an appropriate keybinding, for example:

 , ((modm .|. controlMask, xK_n), appendFilePrompt def "/home/me/NOTES")

Additional notes can be added via regular Haskell or XMonad functions; for example, to preface notes with the time they were made, one could write a binding like

,  ((modm .|. controlMask, xK_n), do
           spawn ("date>>"++"/home/me/NOTES")
           appendFilePrompt def "/home/me/NOTES"
       )

(Put the spawn on the line after the prompt to append the time instead.)

appendFilePrompt' can be used to transform the string input in the prompt before saving into the file. Previous example with date can be rewritten as:

,  ((modm .|. controlMask, xK_n), do
           date <- io $ fmap (formatTime defaultTimeLocale "[%Y-%m-%d %H:%M] ") getZonedTime
           appendFilePrompt' def (date ++) $ "/home/me/NOTES"
       )

A benefit is that if the prompt is cancelled the date is not output to the file too.

For detailed instructions on editing your key bindings, see XMonad.Doc.Extending.

appendFilePrompt :: XPConfig -> FilePath -> X () Source #

Given an XPrompt configuration and a file path, prompt the user for a line of text, and append it to the given file.

appendFilePrompt' :: XPConfig -> (String -> String) -> FilePath -> X () Source #

Given an XPrompt configuration, string transformation function and a file path, prompt the user for a line of text, transform it and append the result to the given file.