I added (ranger.override { imagePreviewSupport = true; })
I think this shouldn’t be necessary, as it already defaults to true
.
w3mimgdisplay
is not availabe as a package
A simple trick for finding the right package is to use NixOS’s command-not-found
helper:
$ command-not-found 'w3mimgdisplay'
The program 'w3mimgdisplay' is not in your PATH. It is provided by several packages.
You can make it available in an ephemeral shell by typing one of the following:
nix-shell -p w3m
nix-shell -p w3m-nox
The problem you’re running into isn’t a missing w3mimgdisplay
, though; ranger shows a different error message in that situation, and in NixOS ranger has been modified to access w3mimgdisplay
through the w3m
package, which is installed automatically as a dependency.
the error message Failed to execute w3mimgdisplay
is displayed
This happens when ranger is able to send commands to w3mimgdisplay
but receives an unexpected response back from it. So maybe w3mimgdisplay
is returning an error message that we can’t see. As a first guess, are you using Wayland? It looks like w3mimgdisplay
doesn’t support that and ranger just expects it to fail like this out of the box.
i installed ueberzug
but ranger still complains
ranger won’t detect Überzug automatically; by default it uses w3m. To use a different method, configure that in your ~/.config/ranger/rc.conf
:
set preview_images_method ueberzug
As an alternative to installing Überzug directly, you might prefer to add it just as a dependency of ranger. This is a little ugly, but matches the technique already used for w3mimgdisplay
:
ranger.overrideAttrs (r: {
preConfigure = r.preConfigure + ''
# Specify path to Überzug
substituteInPlace ranger/ext/img_display.py \
--replace "Popen(['ueberzug'" \
"Popen(['${pkgs.ueberzug}/bin/ueberzug'"
# Use Überzug as the default method
substituteInPlace ranger/config/rc.conf \
--replace 'set preview_images_method w3m' \
'set preview_images_method ueberzug'
'';
})
Ideally something like that would be built in as an option of the ranger package.
If the problem is Wayland compatibility, though, Überzug still won’t help you. There’s some unresolved discussion around this that you might want to keep an eye on. At a glance it looks like only the terminal-specific methods (e.g. kitty) are available.