aboutsummaryrefslogtreecommitdiff
path: root/dotfiles/.local
diff options
context:
space:
mode:
authorYaroslav de la Peña Smirnov <yps@yaroslavps.com>2021-12-21 01:52:47 +0300
committerYaroslav de la Peña Smirnov <yps@yaroslavps.com>2021-12-21 01:52:47 +0300
commitbdce2cfb10a204042a35cf574669cb46950e679f (patch)
tree88c1694b469dd6d69fd37a45bc3d1047c9b489eb /dotfiles/.local
parent8ee1282b5e364f7fa19f0631489b1f74b7525a95 (diff)
downloadswayrice-bdce2cfb10a204042a35cf574669cb46950e679f.tar.gz
swayrice-bdce2cfb10a204042a35cf574669cb46950e679f.zip
Switch to nsxiv as main image viewer
sxiv is no longer maintained.
Diffstat (limited to 'dotfiles/.local')
-rwxr-xr-xdotfiles/.local/bin/nsxiv-rifle29
-rw-r--r--dotfiles/.local/share/applications/nsxiv.desktop8
2 files changed, 37 insertions, 0 deletions
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
diff --git a/dotfiles/.local/share/applications/nsxiv.desktop b/dotfiles/.local/share/applications/nsxiv.desktop
new file mode 100644
index 0000000..adb015a
--- /dev/null
+++ b/dotfiles/.local/share/applications/nsxiv.desktop
@@ -0,0 +1,8 @@
+[Desktop Entry]
+Type=Application
+Name=nsxiv
+GenericName=Image Viewer
+Exec=nsxiv-rifle %F
+MimeType=image/bmp;image/gif;image/jpeg;image/jpg;image/png;image/tiff;image/x-bmp;image/x-portable-anymap;image/x-portable-bitmap;image/x-portable-graymap;image/x-tga;image/x-xpixmap;image/webp;
+NoDisplay=true
+Icon=nsxiv