ranger image-preview with transparent terminal background

14,731

Solution 1

I have a transparent terminal that works with ranger's image preview. I use termite (terminal emulator) and compton (compositor) for transparency (a nice combo when you use i3wm).

Here's the result:

enter image description here

The only problems I had were with tmux (images are displayed, but not always at the right position and sometimes the terminal needs to be refreshed).

Note that the text and the image are also transparent since transparency is handled by compton. This only works if you don't add too much transparency, else you need a terminal emulator that handles transparency and works with this feature (I tried with terminator and I did not work for instance, same for urxvt). 85% opacity gives me some transparency and good readability, so this setup works for me.

Update

True transparency is supported once again in termite, but it suffers from the same issues as urxvt when you enable transparency (failed to execute w3mimgdisplay error, cf. @slm's answer).

Solution 2

Not sure what terminal you're using but if it's using a bit-depth of 32 or higher then it won't work.

excerpt - Images in terminal

Side note: w3m can't render images in urxvt, if the depth is 32. That means that you can't render images on a transparent background. Be sure that you comment the line URxvt*depth: 32 in your ~/.Xresources.

This thread also discussed it as well: - w3m/ranger images don't work on urxvt.

excerpt

It doesn't work with transparent terminals. I always make a shortcut for a "special ranger terminal" that has transparency disabled.

Share:
14,731

Related videos on Youtube

wigeon
Author by

wigeon

Updated on September 18, 2022

Comments

  • wigeon
    wigeon almost 2 years

    I like the image-preview in ranger, but I also like my terminal transparent.

    Is there really no way to get the image-preview work with w3m and transparent background? (I'm willing to change my terminal-emulator if that's necessary, currently urxvt)

  • wigeon
    wigeon almost 10 years
    It was so simple^^ just put opacity-rule = ["85:class_g = 'Termite'"]; in the compton config file :-) thank's I couldn't be happier
  • wigeon
    wigeon almost 10 years
    Oh just one Question, how did you get the text non-transparent?
  • BenC
    BenC almost 10 years
    The text follows the same transparency rule since compton has no way to distinguish text from the rest, it only handles windows. If you want way more transparency, then you need a terminal that takes care of transparency itself (like terminator) while working with this feature (terminator doesn't iirc). In my case, I want a dark background for readability so this setup works pretty well for me, and it is much lighter than alternatives I used before.
  • BenC
    BenC almost 10 years
    Also, since I'm using vim, I have an extra compton rule that sets the opacity to 100% when I'm editing files in vim.
  • villasv
    villasv almost 8 years
    any update on this issue as of today? at least an alternative to w3mimagedisplay?
  • Nikos Alexandris
    Nikos Alexandris almost 8 years
    How ir-relevant is this one: lists.gnu.org/archive/html/ranger-users/2013-06/msg00003.htm‌​l? Will there be a working image preview in ranger within from Konsole for example?
  • tuk0z
    tuk0z almost 8 years
    Ranger 1.7.2 with urxvt 9.22 transparent has image preview. That's with ranger default configuration set preview_images true, set preview_images_method w3m and urxvt Native transparency. It even works in tmux but only for an instant :)