Welcome to Vifm Q&A, where you can ask questions about Vifm usage. Registration is optional, anonymous posts are moderated. GitHub or Google logins are enabled.
0 votes
in vifm by

Problem: with the command

filextype *.bmp,*.jpg,*.jpeg,*.png,*.gif,*.xpm
        \ {View in sxiv}
        \ sxiv %f,

the image opens in sxiv, but it's not possible to go to the next image within sxiv.

Does anybody have a script/command with which it is possible to go to the previous/next image without leaving sxiv?

I found this script for ranger, but I can't make it work in vifm.

2 Answers

0 votes
by

That script doesn't seem to be tied to ranger, it probably should work. Anyway, what I use is below. That script has comments that it's slow, maybe this one is faster (however, it passes all files to sxiv and lets it figure out which one it supports).

filextype *.bmp,*.jpg,*.jpeg,*.png,*.gif,*.xpm
        \ {View in sxiv}
        \ play_images %c -Z -q %i &,

And $VIFM/scripts/play_images is this script:

#!/bin/bash

shopt -s nullglob

if [[ ! -f $1 ]]; then
    echo "$0: first argument is not a file" >&2
    exit 1
fi

file=$(basename -- "$1")
dir=$(dirname -- "$1")
arr=()
shift

cd -- "$dir"

for i in *; do
    [[ -f "$i" ]] || continue
    arr+=("$i")
    [[ "$i" == "$file" ]] && n=${#arr[@]}
done

exec sxiv -n "$n" "$@" "${arr[@]}"

I think it's source is inknoir (this is a nick name) and that it might be based
on script for mplayer from ArchWiki. I remember doing some changes to it, but
don't remember which changes.

0 votes
by

I don't know if this wasn't possible in earlier versions, but with version 26 you can simply do:

sxiv -r -q *
by

It was, the point of the script is to compute correct value for -n parameter.

...