summaryrefslogtreecommitdiffhomepage
path: root/src/Plugins/PipeReader.hs
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2012-09-15 21:04:55 +0200
committerJose Antonio Ortega Ruiz <jao@gnu.org>2012-09-15 21:04:55 +0200
commitacdbb2a628f9b3876a5f97f0c2e6ae6a85d6c290 (patch)
treef756277a9f061c86cbb4de823ac1f034f6a2fd8b /src/Plugins/PipeReader.hs
parent3e7c8cf1a4cd9ea86fd7d1dce13e305dd09fb6fe (diff)
parente2407925093dfcc4e89dabeceb46429adda015b9 (diff)
downloadxmobar-acdbb2a628f9b3876a5f97f0c2e6ae6a85d6c290.tar.gz
xmobar-acdbb2a628f9b3876a5f97f0c2e6ae6a85d6c290.tar.bz2
Merge remote-tracking branch 'rethab/master' into rethab
Diffstat (limited to 'src/Plugins/PipeReader.hs')
-rw-r--r--src/Plugins/PipeReader.hs10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/Plugins/PipeReader.hs b/src/Plugins/PipeReader.hs
index 3fd0dd4..42ae500 100644
--- a/src/Plugins/PipeReader.hs
+++ b/src/Plugins/PipeReader.hs
@@ -23,6 +23,12 @@ data PipeReader = PipeReader String String
instance Exec PipeReader where
alias (PipeReader _ a) = a
start (PipeReader p _) cb = do
- h <- openFile p ReadWriteMode
+ let (def, pipe) = split ':' p
+ h <- openFile pipe ReadWriteMode
+ cb def
forever (hGetLineSafe h >>= cb)
- where forever a = a >> forever a
+ where
+ forever a = a >> forever a
+ split c xs | c `elem` xs = let (pre, post) = span ((/=) c) xs
+ in (pre, dropWhile ((==) c) post)
+ | otherwise = ([], xs)