summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--Config.hs3
-rw-r--r--Plugins/StdinReader.hs26
2 files changed, 28 insertions, 1 deletions
diff --git a/Config.hs b/Config.hs
index 0493476..bc01f44 100644
--- a/Config.hs
+++ b/Config.hs
@@ -24,6 +24,7 @@ import {-# SOURCE #-} Runnable
import Plugins.Monitors
import Plugins.Date
import Plugins.PipeReader
+import Plugins.StdinReader
-- $config
-- Configuration data type and default configuration
@@ -69,5 +70,5 @@ defaultConfig =
-- the 'Runnable.Runnable' Read instance. To install a plugin just add
-- the plugin's type to the list of types appearing in this function's type
-- signature.
-runnableTypes :: (Command,(Monitors,(Date,(PipeReader,()))))
+runnableTypes :: (Command,(Monitors,(Date,(PipeReader,(StdinReader,())))))
runnableTypes = undefined
diff --git a/Plugins/StdinReader.hs b/Plugins/StdinReader.hs
new file mode 100644
index 0000000..7ad2b41
--- /dev/null
+++ b/Plugins/StdinReader.hs
@@ -0,0 +1,26 @@
+-----------------------------------------------------------------------------
+-- |
+-- Module : Plugins.StdinReader
+-- Copyright : (c) Andrea Rossato
+-- License : BSD-style (see LICENSE)
+--
+-- Maintainer : Andrea Rossato <andrea.rossato@unibz.it>
+-- Stability : unstable
+-- Portability : unportable
+--
+-- A plugin for reading from stdin
+--
+-----------------------------------------------------------------------------
+
+module Plugins.StdinReader where
+
+import System.IO
+import Plugins
+
+data StdinReader = StdinReader
+ deriving (Read, Show)
+
+instance Exec StdinReader where
+ start StdinReader cb = do
+ forever (hGetLine stdin >>= cb)
+ where forever a = a >> forever a