summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2012-06-23 02:48:03 +0200
committerhut <hut@lavabit.com>2012-06-23 02:48:44 +0200
commitdcbc83fe390c5291bb442b67b4e909d7f9afadf0 (patch)
tree83a2fd7e853607c62176b45f1c28aee17ffd2b21
parente72815692e7fb66a452a930646c1fd31aafefa9e (diff)
downloadranger-dcbc83fe390c5291bb442b67b4e909d7f9afadf0.tar.gz
added doc/sxivall.sh
-rwxr-xr-xdoc/sxivall.sh25
1 files changed, 25 insertions, 0 deletions
diff --git a/doc/sxivall.sh b/doc/sxivall.sh
new file mode 100755
index 00000000..228114ce
--- /dev/null
+++ b/doc/sxivall.sh
@@ -0,0 +1,25 @@
+#!/bin/bash
+#
+# 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 = sxivall.sh -- "$@"
+#
+
+[ "$1" == '--' ] && shift
+target="$(realpath -s "$1")"
+function listfiles {
+  find "$(dirname "$target")" -maxdepth 1 -type f -iregex '.*\(jpe?g\|bmp\|png\|gif\)$' -print0 | sort -z
+}
+
+count="$(listfiles | grep -m 1 -Zznx "$target" | cut -d: -f1)"
+
+if [ -n "$count" ]; then
+  listfiles | xargs -0 sxiv -n "$count" --
+else
+  sxiv -- "$@" # fallback
+fi