summaryrefslogtreecommitdiff
path: root/Pancake.hs
diff options
context:
space:
mode:
authordefanor <defanor@uberspace.net>2017-10-30 11:53:09 +0300
committerdefanor <defanor@uberspace.net>2017-10-30 11:53:09 +0300
commitbdd98f68eb0134be586a44235364d12b192f32aa (patch)
treed5e118c673957111f061848d907555a79096df5f /Pancake.hs
parentb6f4091a1c2f6e39548a9228594a4f677855cd29 (diff)
Invoke external viewers properly
Set an environment variable for file name.
Diffstat (limited to 'Pancake.hs')
-rw-r--r--Pancake.hs16
1 files changed, 11 insertions, 5 deletions
diff --git a/Pancake.hs b/Pancake.hs
index 9338ddc..014462c 100644
--- a/Pancake.hs
+++ b/Pancake.hs
@@ -397,10 +397,11 @@ instance Default Config where
, ("gopher", "curl \"${URI}\"")]
, defaultCommand = "curl -4 -L \"${URI}\""
, externalViewers = M.fromList $
- map (flip (,) "emacsclient -n") ["hs", "cabal", "c", "h", "el", "scm", "idr"]
- ++ map (flip (,) "xdg-open") [ "svg", "png", "jpg", "jpeg", "gif", "pdf"
- , "ogg", "ogv", "webm", "mp3", "mp4", "mkv"
- , "mpeg", "wav" ]
+ map (flip (,) "emacsclient -n \"${FILE}\"")
+ ["hs", "cabal", "c", "h", "el", "scm", "idr"]
+ ++ map (flip (,) "xdg-open \"${FILE}\"")
+ [ "svg", "png", "jpg", "jpeg", "gif", "pdf", "ogg", "ogv"
+ , "webm", "mp3", "mp4", "mkv", "mpeg", "wav" ]
, shortcuts = M.fromList
[ ("ddg", "https://duckduckgo.com/lite/?q=")
, ("wp", "https://en.m.wikipedia.org/wiki/Special:Search?search=")
@@ -539,7 +540,12 @@ command (GoTo u') = do
, cmd, "`: ", show e])) $ do
createDirectoryIfMissing True dir
BS.writeFile tmpPath d
- callCommand $ concat [ev, " ", tmpPath]
+ curEnv <- getEnvironment
+ ec <- withCreateProcess
+ ((shell ev) { env = Just (("FILE", tmpPath) : curEnv) }) $
+ \_ _ _ p -> waitForProcess p
+ when (ec /= ExitSuccess) $
+ putErrLn $ concat ["An error occured. Exit code: ", show ec]
pure mzero
case d of
Nothing -> pure ()