alacritty: w3mimgdisplay not working correctly

Which operating system does the issue occur on? Void Linux

If on linux, are you using X11 or Wayland? X11

As the title implies image previews for ranger are not behaving correctly for me. Instead of displaying the image properly the preview pane simply stays empty. I can confirm that using the same methods in the urxvt-terminal leads to the images beeing displayed properly. The issue persist whether or not I am using a composite manager (compton).

Configurations used: set preview_images true set preview_images_method w3m

set preview_images true set use_preview_script true set preview_script /usr/share/doc/ranger/config/scope.sh Taken from Issue #107

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 14
  • Comments: 33 (9 by maintainers)

Commits related to this issue

Most upvoted comments

Closing since there’s no change Alacritty is going to make to better support w3m. If it doesn’t work right, it’s because w3m is a massive hack.

I guess that the only non-hacky way to make this working is to incorporate image preview functionality into the terminal itself (like Kitty or Terminology do). Writing this mostly to subscribe on a thread 😃

A workaround is available here, by replacing w3m by ueberzug. I just tested it and it works for me. The dotfiles are available as well, and here is the commit Alkeryn made : https://github.com/Alkeryn/dotfiles/commit/c4f7072909f95a8ad3c0c137925cc3f2123cfb45

https://github.com/thestinger/termite/issues/501#issuecomment-468954048

@FichteFoll I had the same problem, and managed to fix it. Turns out that w3mimgdisplay directly draws on the X11 window of the terminal. If the terminal happens to redraw after that, the image is lost. I believe there is a race condition, Alacritty may or may not swap buffers (or repaint for some other reason) after the image has been drawn. I don’t think this is a bug in Alacritty, just that w3mimgdisplay is a huge hack.

Edit: I feel a need to say that the hack was probably born out of necessity and appreciate the hard work of its author, despite my harsh words.

Edit 2: The script still seems to fail when the throbber is shown in the top right corner of ranger.

I wrote a Bash script that delays image drawing requests by 100ms, which was enough to make the preview stable:

#!/bin/bash
{ 
  while read line; do 
    firstchar=${line:0:1}
    if [[ $firstchar = '0' ]]; then
      # Showing a picture - pause for a moment, in case the terminal has a pending redraw.
      sleep 0.1
    fi
    echo "$line"
  done; 
} | /usr/lib/w3m/w3mimgdisplay

You can make Ranger use that by exporting W3MIMGDISPLAY_PATH to point to the script. Note that the script references w3mimgdisplay by its absolute path, you might need to change it depending on your distro.

Oh and moreover, I have found that calling neofetch --w3m /path/to/image (neofetch is a sysinfo-script that can display pictures in the terminal using the w3m backend) also does not produce the correct result. So the issue should most definitely not be related to ranger.

ok a update alacritty image preview works on gnome under xorg but it does not work under BSPWM which is quite odd 😕

This works for X11 but not for alacritty in wayland

ranger’s preview works for me most of the time, but occasionally the image only shows up for a brief period of time and then disappears. This seems to be related to w3m moreso than ranger, but I don’t know anything about the internals

For me the preview in ranger works but running neofetch --w3m /path/to/image flashes the image briefly and then doesn’t show it. I’m using AwesomeWM.

I have to say that alacritty and w3m doesn’t go well together, ranger, w3m or anything that is related with w3mimgdisplay does not work for me. while urxvt works flawlessly been trying everything to get image preview to work on alacritty 😦

You can work around this by running neofetch with --loop :

Redraw the image constantly until Ctrl+C is used. This fixes issues in some terminals emulators when using image mode.

o.O I guess that’ll do it. Installed and working now!

@strogiyotec i don’t think w3mimgdisplay works in wayland either, afaik they both work by doing a draw using xorg.

For me ueberzug does not work with ranger in alacritty. Still searching for a solution

FWIW, this rc.conf works perfectly with alacritty.

set preview_images true
set preview_images_method ueberzug
set use_preview_script true
set preview_script ~/.config/ranger/scope.sh

Do you have w3m installed? It’s a tool that is actually rendering the images.

Details: click