about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorWojciech Siewierski <wojciech.siewierski@onet.pl>2019-06-13 02:12:52 +0200
committerGitHub <noreply@github.com>2019-06-13 02:12:52 +0200
commit5dd0d02b2dce50c5762c1bdf11a064dc38df7f2e (patch)
treeb8bdadd60843e5a1e4b5b7f1ed0c7d905f10c393
parent712fa397f860a29e0a38a92ad441e04de0ff93ec (diff)
parent84dfcac54d1c07c18bc8fd3ba61a8fe957c67757 (diff)
downloadranger-5dd0d02b2dce50c5762c1bdf11a064dc38df7f2e.tar.gz
Merge pull request #1567 from FichteForks/pr/safe-image-wd
Open image displaying subprocesses in safe workdir
-rw-r--r--ranger/ext/img_display.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/ranger/ext/img_display.py b/ranger/ext/img_display.py
index 7c9f35a7..2cce5c7a 100644
--- a/ranger/ext/img_display.py
+++ b/ranger/ext/img_display.py
@@ -75,6 +75,8 @@ class ImgDisplayUnsupportedException(Exception):
 class ImageDisplayer(object):
     """Image display provider functions for drawing images in the terminal"""
 
+    working_dir = os.environ.get('XDG_RUNTIME_DIR', os.path.expanduser("~") or None)
+
     def draw(self, path, start_x, start_y, width, height):
         """Draw an image at the given coordinates."""
         pass
@@ -106,7 +108,7 @@ class W3MImageDisplayer(ImageDisplayer, FileManagerAware):
         """start w3mimgdisplay"""
         self.binary_path = None
         self.binary_path = self._find_w3mimgdisplay_executable()  # may crash
-        self.process = Popen([self.binary_path] + W3MIMGDISPLAY_OPTIONS,
+        self.process = Popen([self.binary_path] + W3MIMGDISPLAY_OPTIONS, cwd=self.working_dir,
                              stdin=PIPE, stdout=PIPE, universal_newlines=True)
         self.is_initialized = True
 
@@ -696,7 +698,7 @@ class UeberzugImageDisplayer(ImageDisplayer):
                 and not self.process.stdin.closed):
             return
 
-        self.process = Popen(['ueberzug', 'layer', '--silent'],
+        self.process = Popen(['ueberzug', 'layer', '--silent'], cwd=self.working_dir,
                              stdin=PIPE, universal_newlines=True)
         self.is_initialized = True