From a0a1865dd268e50c77a5a8dea09a46da7408fd54 Mon Sep 17 00:00:00 2001 From: Reto Habluetzel Date: Sat, 15 Sep 2012 16:34:35 +0200 Subject: Enhanced PipeReader capabilities * Removed PipeReader2 * PipeReader pipename can be prefixed with default. (e.g. "I am default:/home/foo/pipe") --- src/Config.hs | 3 +-- src/Plugins/PipeReader.hs | 10 ++++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Config.hs b/src/Config.hs index 58956af..a6ad3e2 100644 --- a/src/Config.hs +++ b/src/Config.hs @@ -28,7 +28,6 @@ import {-# SOURCE #-} Runnable import Plugins.Monitors import Plugins.Date import Plugins.PipeReader -import Plugins.PipeReader2 import Plugins.BufferedPipeReader import Plugins.CommandReader import Plugins.StdinReader @@ -121,7 +120,7 @@ infixr :*: -- the 'Runnable.Runnable' Read instance. To install a plugin just add -- the plugin's type to the list of types (separated by ':*:') appearing in -- this function's type signature. -runnableTypes :: Command :*: Monitors :*: Date :*: PipeReader :*: PipeReader2 :*: BufferedPipeReader :*: CommandReader :*: StdinReader :*: XMonadLog :*: EWMH :*: Kbd :*: +runnableTypes :: Command :*: Monitors :*: Date :*: PipeReader :*: BufferedPipeReader :*: CommandReader :*: StdinReader :*: XMonadLog :*: EWMH :*: Kbd :*: #ifdef INOTIFY Mail :*: MBox :*: #endif diff --git a/src/Plugins/PipeReader.hs b/src/Plugins/PipeReader.hs index 3fd0dd4..42ae500 100644 --- a/src/Plugins/PipeReader.hs +++ b/src/Plugins/PipeReader.hs @@ -23,6 +23,12 @@ data PipeReader = PipeReader String String instance Exec PipeReader where alias (PipeReader _ a) = a start (PipeReader p _) cb = do - h <- openFile p ReadWriteMode + let (def, pipe) = split ':' p + h <- openFile pipe ReadWriteMode + cb def forever (hGetLineSafe h >>= cb) - where forever a = a >> forever a + where + forever a = a >> forever a + split c xs | c `elem` xs = let (pre, post) = span ((/=) c) xs + in (pre, dropWhile ((==) c) post) + | otherwise = ([], xs) -- cgit v1.2.3