From 48e62d3cffe28d46016f827066e98f1b1c47b358 Mon Sep 17 00:00:00 2001 From: Andrea Rossato Date: Thu, 27 Sep 2007 19:35:29 +0200 Subject: Added a plugin to read named pipes (such as an XMonad logger) darcs-hash:20070927173529-d6583-e817ee89a436f2d6d8f3c888244c2cd9c2603546.gz --- Plugins/PipeReader.hs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Plugins/PipeReader.hs diff --git a/Plugins/PipeReader.hs b/Plugins/PipeReader.hs new file mode 100644 index 0000000..8fa2e8e --- /dev/null +++ b/Plugins/PipeReader.hs @@ -0,0 +1,28 @@ +----------------------------------------------------------------------------- +-- | +-- Module : Plugins.PipeReader +-- Copyright : (c) Andrea Rossato +-- License : BSD-style (see LICENSE) +-- +-- Maintainer : Andrea Rossato +-- Stability : unstable +-- Portability : unportable +-- +-- A plugin for reading from named pipes +-- +----------------------------------------------------------------------------- + +module Plugins.PipeReader where + +import System.IO +import Plugins + +data PipeReader = PipeReader String + deriving (Read, Show) + +instance Exec PipeReader where + alias (PipeReader p) = p + start (PipeReader p) cb = do + h <- openFile p ReadMode + forever (hGetLine h >>= cb) + where forever a = a >> forever a -- cgit v1.2.3