summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Config.hs3
-rw-r--r--src/Plugins/PipeReader2.hs30
2 files changed, 32 insertions, 1 deletions
diff --git a/src/Config.hs b/src/Config.hs
index a6ad3e2..58956af 100644
--- a/src/Config.hs
+++ b/src/Config.hs
@@ -28,6 +28,7 @@ import {-# SOURCE #-} Runnable
import Plugins.Monitors
import Plugins.Date
import Plugins.PipeReader
+import Plugins.PipeReader2
import Plugins.BufferedPipeReader
import Plugins.CommandReader
import Plugins.StdinReader
@@ -120,7 +121,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 :*: BufferedPipeReader :*: CommandReader :*: StdinReader :*: XMonadLog :*: EWMH :*: Kbd :*:
+runnableTypes :: Command :*: Monitors :*: Date :*: PipeReader :*: PipeReader2 :*: BufferedPipeReader :*: CommandReader :*: StdinReader :*: XMonadLog :*: EWMH :*: Kbd :*:
#ifdef INOTIFY
Mail :*: MBox :*:
#endif
diff --git a/src/Plugins/PipeReader2.hs b/src/Plugins/PipeReader2.hs
new file mode 100644
index 0000000..511f107
--- /dev/null
+++ b/src/Plugins/PipeReader2.hs
@@ -0,0 +1,30 @@
+-----------------------------------------------------------------------------
+-- |
+-- Module : Plugins.PipeReader2
+-- Copyright : (c) Andrea Rossato
+-- License : BSD-style (see LICENSE)
+--
+-- Maintainer : Jose A. Ortega Ruiz <jao@gnu.org>
+-- Stability : unstable
+-- Portability : unportable
+--
+-- A plugin for reading from named pipes. As opposed to PipeReader, this
+-- plugin displays a default string when it starts.
+--
+-----------------------------------------------------------------------------
+
+module Plugins.PipeReader2 where
+
+import System.IO
+import Plugins
+
+data PipeReader2 = PipeReader2 String String String
+ deriving (Read, Show)
+
+instance Exec PipeReader2 where
+ alias (PipeReader2 _ a _) = a
+ start (PipeReader2 p _ def) cb = do
+ h <- openFile p ReadWriteMode
+ cb def
+ forever (hGetLineSafe h >>= cb)
+ where forever a = a >> forever a