diff options
Diffstat (limited to 'plugins/imgview')
-rwxr-xr-x | plugins/imgview | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/plugins/imgview b/plugins/imgview index 9370ae5..d221f98 100755 --- a/plugins/imgview +++ b/plugins/imgview @@ -2,6 +2,9 @@ # Description: Open images in hovered directory and thumbnails # open hovered image in sxiv or viu and browse other images in the directory +# Dependencies: imv (https://github.com/eXeC64/imv) or, +# sxiv (https://github.com/muennich/sxiv) or, +# viu (https://github.com/atanunq/viu), less # # Shell: POSIX compliant # Author: Arun Prakash Jana @@ -18,14 +21,15 @@ listimages() { '.*\(jpe?g\|bmp\|png\|gif\)$' -print0 | sort -z } -sxiv_view_dir() { - target="$(abspath "$1")" +view_dir() { + target="$(abspath "$2")" count="$(listimages | grep -a -m 1 -ZznF "$target" | cut -d: -f1)" if [ -n "$count" ]; then - listimages | xargs -0 sxiv -n "$count" -- + listimages | xargs -0 "$1" -n "$count" -- else - sxiv -- "$@" # fallback + shift + "$1" -- "$@" # fallback fi } @@ -35,16 +39,22 @@ if [ -z "$1" ] || ! [ -s "$1" ]; then exit 1 fi -if command -v sxiv >/dev/null 2>&1; then +if command -v imvr >/dev/null 2>&1; then if [ -f "$1" ]; then - sxiv_view_dir "$1" >/dev/null 2>&1 & + view_dir imvr "$1" >/dev/null 2>&1 & + elif [ -d "$1" ] || [ -h "$1" ]; then + imvr "$1" >/dev/null 2>&1 & + fi +elif command -v sxiv >/dev/null 2>&1; then + if [ -f "$1" ]; then + view_dir sxiv "$1" >/dev/null 2>&1 & elif [ -d "$1" ] || [ -h "$1" ]; then sxiv -qt "$1" >/dev/null 2>&1 & fi elif command -v viu >/dev/null 2>&1; then viu -n "$1" | less -R else - printf "install sxiv or viu" + printf "install imv/sxiv/viu" read -r _ exit 2 fi |