2023-08-05 Update

The drop-in replacement ueberzugpp has native support for Wayland (sway and hyprland), and most importantly, tmux support on sway and hyprland!

pacman -Syu ueberzugpp and then add the following:

set preview_images true
set preview_images_method ueberzug

vimiv

imv-result

and you’re done!

TL;DR
I’ve switched to using vimiv to substitute for my broken Ranger’s image preview. You could also use imv or mpv to interact with Ranger but I found it to be a bit janky.

Working fine until something broke…

Five months ago, I asked for help on Reddit: [Sway + Kitty + Tmux + Ranger’s Image Preview] Not working but worked in X11. Long story short, the absolute is that Kitty + Tmux + Ranger’s image preview isn’t going to work (#413), but Kitty + Ranger (i.e., without Tmux) works fine, so I had the following:

~/.config/ranger/rc.conf:

set preview_images true
set preview_images_method kitty

~/.config/sway/config.d/autostart_applications:

# ╭──────────────────────────────────────────────────────────╮
# │ Dropdown terminals                                       │
# ╰──────────────────────────────────────────────────────────╯
    for_window {
        [app_id="dropdown_top"] floating enable
        [app_id="dropdown_top"] move scratchpad
    }
    exec {
        --no-startup-id kitty --class dropdown_top
    }
    bindsym {
        $mod+t [app_id="dropdown_top"] scratchpad show; [app_id="dropdown_top"] resize set 55 ppt 45 ppt, move position 20ppt -5px
    }

If I want to use Ranger’s image preview, I’d press $mod+t and launch this kitty floating terminal.

Something broke today

Today my Ranger or kitty broke. For reference: No image preview support for WezTerm. I’ll no longer try to do image preview inside Ranger, so I’ve resorted to using an external tool.

vimiv

I’ve looked through Are we Wayland yet? and Useful add ons for sway vimiv and found that vimiv is the best substitute for Ranger’s image preview. Vimiv: The Love Child Of Ranger And Sxiv.

~/.config/vimiv/keys.conf:

gr : !dragon-drop %%
gp : !pinta %%

vimiv could do what I want: drag and drop to other applications and use pinta to edit the current image.

vimiv

mpv or imv if you still want to use Ranger’s Image Preview

mpv or imv works:

imv-result

The benefit is that scrolling in Ranger would automatically refresh the image in imv or mpv. The bad is that, when you’re done viewing images, you need to quit Ranger, not imv or mpv. If you quit imv or mpv first, when you go back to Ranger, it’ll start imv or mpv again. So if you start ranger in a directory of images, imv or mpv would start automatically and I find it to be annyoing.