From bdce2cfb10a204042a35cf574669cb46950e679f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yaroslav=20de=20la=20Pe=C3=B1a=20Smirnov?= Date: Tue, 21 Dec 2021 01:52:47 +0300 Subject: Switch to nsxiv as main image viewer sxiv is no longer maintained. --- dotfiles/.local/bin/nsxiv-rifle | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 dotfiles/.local/bin/nsxiv-rifle (limited to 'dotfiles/.local/bin') diff --git a/dotfiles/.local/bin/nsxiv-rifle b/dotfiles/.local/bin/nsxiv-rifle new file mode 100755 index 0000000..95d6423 --- /dev/null +++ b/dotfiles/.local/bin/nsxiv-rifle @@ -0,0 +1,29 @@ +#!/bin/sh + +if [ $# -eq 0 ]; then + echo "Usage: ${0##*/} PICTURES" + exit +fi + +[ "$1" = '--' ] && shift + +abspath () { + case "$1" in + /*) printf "%s\n" "$1";; + *) printf "%s\n" "$PWD/$1";; + esac +} + +listfiles () { + find -L "$(dirname "$target")" -maxdepth 1 -type f -iregex \ + '.*\(jpe?g\|bmp\|webp\|png\|gif\)$' -print0 | sort -z +} + +target="$(abspath "$1")" +count="$(listfiles | grep -m 1 -ZznF "$target" | cut -d: -f1)" + +if [ -n "$count" ]; then + listfiles | xargs -0 nsxiv -a -n "$count" -- +else + nsxiv -a -- "$@" # fallback +fi -- cgit v1.2.3