diff options
author | defanor <defanor@uberspace.net> | 2017-10-30 11:53:09 +0300 |
---|---|---|
committer | defanor <defanor@uberspace.net> | 2017-10-30 11:53:09 +0300 |
commit | bdd98f68eb0134be586a44235364d12b192f32aa (patch) | |
tree | d5e118c673957111f061848d907555a79096df5f /Pancake.hs | |
parent | b6f4091a1c2f6e39548a9228594a4f677855cd29 (diff) |
Invoke external viewers properly
Set an environment variable for file name.
Diffstat (limited to 'Pancake.hs')
-rw-r--r-- | Pancake.hs | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -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 () |