>From c44646886ace5b4a463ebae5cd5b47c842e22bbf Mon Sep 17 00:00:00 2001 From: niku Date: Sat, 22 Jun 2013 11:59:58 +0530 Subject: [PATCH 1/2] set W3M_TTY env. variable for using w3mimgdisplay in Linux console In the Linux framebuffer mode, w3mimgdisplay requires the env. variable W3M_TTY to be set to something decent. (Check the code in w3m-*.tar.gz/w3mimg/fb/fb_w3mimg.c.) If used via: `w3m -o 'ext_image_viewer=off' /path/to/image.jpg', w3m sets it for us. Since we are using the library directly, we need to set it by hand. --- ranger/ext/img_display.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ranger/ext/img_display.py b/ranger/ext/img_display.py index b6f59f4..50d8824 100644 --- a/ranger/ext/img_display.py +++ b/ranger/ext/img_display.py @@ -10,12 +10,18 @@ framebuffer) or in a Xorg session. w3m need to be installed for this to work. """ -import termios, fcntl, struct, sys, os +import termios, fcntl, struct, sys, os, subprocess from subprocess import Popen, PIPE W3MIMGDISPLAY_PATH = '/usr/lib/w3m/w3mimgdisplay' W3MIMGDISPLAY_OPTIONS = [] +TTY = subprocess.check_output(['tty']).rstrip('\n') +os.environ['W3M_TTY'] = TTY +# When using the Linux framebuffer (console) w3mimgdisplay requires +# the env variable to be something nice. We need to set it by hand as +# we are calling the library directly, and not via w3m. + class ImgDisplayUnsupportedException(Exception): pass -- 1.7.10.4