summaryrefslogtreecommitdiffhomepage
path: root/src/Plugins
diff options
context:
space:
mode:
authorReto Habluetzel <rethab@rethab.ch>2012-08-27 21:07:54 +0200
committerReto Habluetzel <rethab@rethab.ch>2012-08-27 21:07:54 +0200
commit976312375bbedd05eb822b3b0d5d044aa7d4a3ea (patch)
tree392fbcfe4c34d4c1ca5aa0152844d21215cc9fab /src/Plugins
parente7cadcd8dee8c2e79e338f67cb27b675aba6bac5 (diff)
downloadxmobar-976312375bbedd05eb822b3b0d5d044aa7d4a3ea.tar.gz
xmobar-976312375bbedd05eb822b3b0d5d044aa7d4a3ea.tar.bz2
added PipeReader2 which accepts a default
Diffstat (limited to 'src/Plugins')
-rw-r--r--src/Plugins/PipeReader2.hs30
1 files changed, 30 insertions, 0 deletions
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