summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2013-03-24 22:45:24 +0100
committerhut <hut@lavabit.com>2013-03-24 22:45:24 +0100
commite71e0931a09ee71729582dd99a9a9c2eb987876b (patch)
tree396f0f3330f321e1b1428c7c65d9edee0fbbb294
parent4b3b9e594faf539d96814bfca605405dce7d8086 (diff)
downloadranger-e71e0931a09ee71729582dd99a9a9c2eb987876b.tar.gz
ext.img_display: allow using W3MIMGDISPLAY_PATH env var
in response to https://savannah.nongnu.org/bugs/?38582
-rw-r--r--doc/ranger.16
-rw-r--r--doc/ranger.pod5
-rw-r--r--ranger/ext/img_display.py7
3 files changed, 15 insertions, 3 deletions
diff --git a/doc/ranger.1 b/doc/ranger.1
index cc3c32bb..a8c70ad4 100644
--- a/doc/ranger.1
+++ b/doc/ranger.1
@@ -124,7 +124,7 @@
 .\" ========================================================================
 .\"
 .IX Title "RANGER 1"
-.TH RANGER 1 "ranger-1.6.0" "03/09/2013" "ranger manual"
+.TH RANGER 1 "ranger-1.6.0" "03/24/2013" "ranger manual"
 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
 .\" way too many mistakes in technical documents.
 .if n .ad l
@@ -1093,6 +1093,10 @@ statements.  You will gain efficiency at the cost of losing some debug info.
 .Sp
 Using PYTHONOPTIMIZE=2 (like python \-OO) will additionally discard any
 docstrings.  Using this will disable the <F1> key on commands.
+.IP "W3MIMGDISPLAY_PATH" 8
+.IX Item "W3MIMGDISPLAY_PATH"
+By changing this variable, you can change the path of the executable file for
+image previews.  By default, it is set to \fI/usr/lib/w3m/w3mimgdisplay\fR.
 .SH "EXAMPLES"
 .IX Header "EXAMPLES"
 There are various examples on how to extend ranger with plugins or combine
diff --git a/doc/ranger.pod b/doc/ranger.pod
index 10aa0186..ac9970c5 100644
--- a/doc/ranger.pod
+++ b/doc/ranger.pod
@@ -1176,6 +1176,11 @@ statements.  You will gain efficiency at the cost of losing some debug info.
 Using PYTHONOPTIMIZE=2 (like python -OO) will additionally discard any
 docstrings.  Using this will disable the <F1> key on commands.
 
+=item W3MIMGDISPLAY_PATH
+
+By changing this variable, you can change the path of the executable file for
+image previews.  By default, it is set to F</usr/lib/w3m/w3mimgdisplay>.
+
 =back
 
 
diff --git a/ranger/ext/img_display.py b/ranger/ext/img_display.py
index 9f2fd316..b6f59f4f 100644
--- a/ranger/ext/img_display.py
+++ b/ranger/ext/img_display.py
@@ -10,7 +10,7 @@ framebuffer) or in a Xorg session.
 w3m need to be installed for this to work.
 """
 
-import termios, fcntl, struct, sys
+import termios, fcntl, struct, sys, os
 from subprocess import Popen, PIPE
 
 W3MIMGDISPLAY_PATH = '/usr/lib/w3m/w3mimgdisplay'
@@ -32,7 +32,10 @@ def _get_font_dimensions():
 
 def _w3mimgdisplay(commands):
     """Invoke w3mimgdisplay and send commands on its standard input."""
-    process = Popen([W3MIMGDISPLAY_PATH] + W3MIMGDISPLAY_OPTIONS, stdin=PIPE,
+    path = os.environ.get("W3MIMGDISPLAY_PATH", None)
+    if not path:
+        path = W3MIMGDISPLAY_PATH
+    process = Popen([path] + W3MIMGDISPLAY_OPTIONS, stdin=PIPE,
             stdout=PIPE, universal_newlines=True)
 
     # wait for the external program to finish