summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrea Rossato <andrea.rossato@ing.unitn.it>2007-09-27 19:35:29 +0200
committerAndrea Rossato <andrea.rossato@ing.unitn.it>2007-09-27 19:35:29 +0200
commit48e62d3cffe28d46016f827066e98f1b1c47b358 (patch)
tree9fcbd1489baf1040a1bb56ff9d472939b5b38e70
parent01f56cd3314e629bc2cfe6f4de734c4ee3815b3e (diff)
downloadxmobar-48e62d3cffe28d46016f827066e98f1b1c47b358.tar.gz
xmobar-48e62d3cffe28d46016f827066e98f1b1c47b358.tar.bz2
Added a plugin to read named pipes (such as an XMonad logger)
darcs-hash:20070927173529-d6583-e817ee89a436f2d6d8f3c888244c2cd9c2603546.gz
-rw-r--r--Plugins/PipeReader.hs28
1 files changed, 28 insertions, 0 deletions
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 <andrea.rossato@unibz.it>
+-- 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