diff options
author | Florian Preinstorfer | 2015-06-08 19:41:42 +0200 |
---|---|---|
committer | Florian Preinstorfer | 2015-06-08 19:41:42 +0200 |
commit | 382b955abf11cd960ae61d79b6a3e559cafc82ac (patch) | |
tree | ce0f908a70607ba1c52907bb965696511510bede | |
download | aur-382b955abf11cd960ae61d79b6a3e559cafc82ac.tar.gz |
Initial import
-rw-r--r-- | .SRCINFO | 16 | ||||
-rw-r--r-- | PKGBUILD | 21 | ||||
-rw-r--r-- | sxiv-rifle.desktop | 8 | ||||
-rw-r--r-- | sxiv-rifle.sh | 48 |
4 files changed, 93 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 000000000000..3a00bc57de37 --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,16 @@ +pkgbase = sxiv-rifle + pkgdesc = Browse through images in directory after opening a single file + pkgver = 1.3 + pkgrel = 1 + url = https://wiki.archlinux.org/index.php/Sxiv#Browse_through_images_in_directory_after_opening_a_single_file + arch = i686 + arch = x86_64 + license = GPL2 + depends = sxiv + source = sxiv-rifle.sh + source = sxiv-rifle.desktop + md5sums = 47069e805adcb7654ec3612dde1ee126 + md5sums = 22b56f46c4681b0cb6babdf43bb1d13f + +pkgname = sxiv-rifle + diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 000000000000..a809457f9e7f --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,21 @@ +# Maintainer: Robert Orzanna <orschiro at gmail dot com> + +pkgname=sxiv-rifle +pkgver=1.3 +pkgrel=1 +pkgdesc="Browse through images in directory after opening a single file" +arch=('i686' 'x86_64') +url="https://wiki.archlinux.org/index.php/Sxiv#Browse_through_images_in_directory_after_opening_a_single_file" +license=('GPL2') +depends=('sxiv') +source=('sxiv-rifle.sh' 'sxiv-rifle.desktop') +md5sums=('47069e805adcb7654ec3612dde1ee126' + '22b56f46c4681b0cb6babdf43bb1d13f') + +package() { + cd "$srcdir" + install -Dm755 sxiv-rifle.sh "$pkgdir/usr/bin/sxiv-rifle" + install -Dm644 sxiv-rifle.desktop "$pkgdir/usr/share/applications/sxiv-rifle.desktop" +} + +# vim:set ts=2 sw=2 et: diff --git a/sxiv-rifle.desktop b/sxiv-rifle.desktop new file mode 100644 index 000000000000..1f7d7713e51b --- /dev/null +++ b/sxiv-rifle.desktop @@ -0,0 +1,8 @@ +[Desktop Entry] +Type=Application +Name=sxiv-rifle +GenericName=Image Viewer +Exec=sxiv-rifle %F +MimeType=image/bmp;image/gif;image/jpeg;image/jpg;image/png;image/tiff;image/x-bmp; +NoDisplay=false +Icon=sxiv.png diff --git a/sxiv-rifle.sh b/sxiv-rifle.sh new file mode 100644 index 000000000000..9290bac54339 --- /dev/null +++ b/sxiv-rifle.sh @@ -0,0 +1,48 @@ +#!/bin/sh +# Compatible with ranger 1.6.* +# +# This script searches image files in a directory, opens them all with sxiv and +# sets the first argument to the first image displayed by sxiv. +# +# This is supposed to be used in rifle.conf as a workaround for the fact that +# sxiv takes no file name arguments for the first image, just the number. Copy +# this file somewhere into your $PATH and add this at the top of rifle.conf: +# +# mime ^image, has sxiv, X, flag f = path/to/this/script -- "$@" +# +# Implementation notes: this script is quite slow because of POSIX limitations +# and portability concerns. First calling the shell function 'abspath' is +# quicker than calling 'realpath' because it would fork a whole process, which +# is slow. Second, we need to append a file list to sxiv, which can only be done +# properly in two ways: arrays (which are not POSIX) or \0 sperated +# strings. Unfortunately, assigning \0 to a variable is not POSIX either (will +# not work in dash and others), so we cannot store the result of listfiles to a +# variable. + +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\|png\|gif\)$' -print0 | sort -z +} + +target="$(abspath "$1")" +count="$(listfiles | grep -a -m 1 -ZznF "$target" | cut -d: -f1)" + +if [ -n "$count" ]; then + listfiles | xargs -0 sxiv -n "$count" -- +else + sxiv -- "$@" # fallback +fi |