summaryrefslogtreecommitdiffhomepage
path: root/src/Plugins
diff options
context:
space:
mode:
authorReto Habluetzel <rethab@rethab.ch>2012-09-15 16:34:35 +0200
committerReto Habluetzel <rethab@rethab.ch>2012-09-15 16:34:35 +0200
commita0a1865dd268e50c77a5a8dea09a46da7408fd54 (patch)
treeb47fdcd23a6899e2993817b35ba299b2bd370e6b /src/Plugins
parent1b38bbadb62fa06f5e00ee89e0384591dc522325 (diff)
downloadxmobar-a0a1865dd268e50c77a5a8dea09a46da7408fd54.tar.gz
xmobar-a0a1865dd268e50c77a5a8dea09a46da7408fd54.tar.bz2
Enhanced PipeReader capabilities
* Removed PipeReader2 * PipeReader pipename can be prefixed with default. (e.g. "I am default:/home/foo/pipe")
Diffstat (limited to 'src/Plugins')
-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)