summaryrefslogtreecommitdiffhomepage
path: root/src/Plugins/MarqueePipeReader.hs
diff options
context:
space:
mode:
authorWill Song <incertia9474@gmail.com>2016-07-16 16:15:33 -0500
committerjao <jao@gnu.org>2016-07-27 01:00:06 +0200
commita93755b2d1e9efbd63723f5302ca7c8f43521aa8 (patch)
treefd6478184be41063af8c618e2bb0932179ba18a5 /src/Plugins/MarqueePipeReader.hs
parentc98752cad2343932d42d2fef2229581f0c266800 (diff)
downloadxmobar-a93755b2d1e9efbd63723f5302ca7c8f43521aa8.tar.gz
xmobar-a93755b2d1e9efbd63723f5302ca7c8f43521aa8.tar.bz2
Add expandEnv function and use it in PipeReader family of monitors
expandEnv takes a string and expands the environment variables it can find. variable substringing (e.g. ${VAR:1} to lop off the first character) is not supported, but $VAR and ${VAR} formats are, with the former being delimited by punctuation, but not underscores.
Diffstat (limited to 'src/Plugins/MarqueePipeReader.hs')
-rw-r--r--src/Plugins/MarqueePipeReader.hs3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/Plugins/MarqueePipeReader.hs b/src/Plugins/MarqueePipeReader.hs
index 8120c84..0b3a710 100644
--- a/src/Plugins/MarqueePipeReader.hs
+++ b/src/Plugins/MarqueePipeReader.hs
@@ -15,6 +15,7 @@
module Plugins.MarqueePipeReader where
import System.IO (openFile, IOMode(ReadWriteMode), Handle)
+import Environment
import Plugins (tenthSeconds, Exec(alias, start), hGetLineSafe)
import System.Posix.Files (getFileStatus, isNamedPipe)
import Control.Concurrent(forkIO, threadDelay)
@@ -32,7 +33,7 @@ data MarqueePipeReader = MarqueePipeReader String (Length, Rate, Separator) Stri
instance Exec MarqueePipeReader where
alias (MarqueePipeReader _ _ a) = a
start (MarqueePipeReader p (len, rate, sep) _) cb = do
- let (def, pipe) = split ':' p
+ (def, pipe) <- split ':' <$> expandEnv p
unless (null def) (cb def)
checkPipe pipe
h <- openFile pipe ReadWriteMode