ranger image-preview with transparent terminal background
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:
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 terminalSide 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.
excerptIt doesn't work with transparent terminals. I always make a shortcut for a "special ranger terminal" that has transparency disabled.
Related videos on Youtube
wigeon
Updated on September 18, 2022Comments
-
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 almost 10 yearsIt was so simple^^ just put
opacity-rule = ["85:class_g = 'Termite'"];
in the compton config file :-) thank's I couldn't be happier -
wigeon almost 10 yearsOh just one Question, how did you get the text non-transparent?
-
BenC almost 10 yearsThe 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 (liketerminator
) 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 almost 10 yearsAlso, since I'm using
vim
, I have an extracompton
rule that sets the opacity to 100% when I'm editing files invim
. -
villasv almost 8 yearsany update on this issue as of today? at least an alternative to
w3mimagedisplay
? -
Nikos Alexandris almost 8 yearsHow ir-relevant is this one: lists.gnu.org/archive/html/ranger-users/2013-06/msg00003.html? Will there be a working image preview in ranger within from
Konsole
for example? -
tuk0z almost 8 yearsRanger 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 :)