From 65e6c2d1b7865d1bb0a451653acfc3f19e8f3b22 Mon Sep 17 00:00:00 2001
From: shmibs <shmibs@gmail.com>
Date: Sat, 14 Feb 2015 23:40:26 -0700
Subject: handle multi-file selections

---
 .config/sxiv/exec/key-handler | 65 ++++++++++++++++++++++---------------------
 1 file changed, 33 insertions(+), 32 deletions(-)

(limited to '.config/sxiv/exec')

diff --git a/.config/sxiv/exec/key-handler b/.config/sxiv/exec/key-handler
index cf286c9..9eed7d3 100755
--- a/.config/sxiv/exec/key-handler
+++ b/.config/sxiv/exec/key-handler
@@ -4,35 +4,36 @@
 # where C/M/S indicate Ctrl/Meta(Alt)/Shift modifier states and KEY is the X
 # keysym as listed in /usr/include/X11/keysymdef.h without the "XK_" prefix.
 
-case "$1" in
-"y")
-        echo -n "$2" | xclip -selection clipboard ;;
-"C-d")
-        rm "$2" ;;
-"g")
-        gimp "$2" & ;;
-"s")
-
-	scp "$2" shmibbles.me:/srv/http/tmp/
-	if [ $? -ne 0 ]; then
-		notify-send "uploading $(basename $2) to /tmp/ failed"
-	else
-		name=$(echo "http://shmibbles.me/tmp/$(basename $2)" | sed 's/ /%20/g')
-		echo "$name" | tr -d '\n' | xclip -i -selection clipboard
-		echo "$name" | tr -d '\n' | xclip -i -selection primary
-		notify-send "uploaded $(basename $2) to /tmp/"
-	fi
-	;;
-"i")
-	scp "$2" shmibbles.me:/srv/http/img/
-	if [ $? -ne 0 ]; then
-		notify-send "uploading $(basename $2) to /img/ failed"
-	else
-		name=$(echo "http://shmibbles.me/img/$(basename $2)" | sed 's/ /%20/g')
-		echo "$name" | tr -d '\n' | xclip -i -selection clipboard
-		echo "$name" | tr -d '\n' | xclip -i -selection primary
-		notify-send "uploaded $(basename $2) to /img/"
-	fi
-	;;
-
-esac
+while read file
+do
+	case "$1" in
+	"y")
+		echo -n "$file" | xclip -selection clipboard ;;
+	"C-d")
+		rm "$file" ;;
+	"g")
+		gimp "$file" & ;;
+	"s")
+		scp "$file" shmibbles.me:/srv/http/tmp/
+		if [ $? -ne 0 ]; then
+			notify-send "uploading $(basename $file) to /tmp/ failed"
+		else
+			name=$(echo "http://shmibbles.me/tmp/$(basename $file)" | sed 's/ /%20/g')
+			echo "$name" | tr -d '\n' | xclip -i -selection clipboard
+			echo "$name" | tr -d '\n' | xclip -i -selection primary
+			notify-send "uploaded $(basename $file) to /tmp/"
+		fi
+		;;
+	"i")
+		scp "$file" shmibbles.me:/srv/http/img/
+		if [ $? -ne 0 ]; then
+			notify-send "uploading $(basename $file) to /img/ failed"
+		else
+			name=$(echo "http://shmibbles.me/img/$(basename $file)" | sed 's/ /%20/g')
+			echo "$name" | tr -d '\n' | xclip -i -selection clipboard
+			echo "$name" | tr -d '\n' | xclip -i -selection primary
+			notify-send "uploaded $(basename $file) to /img/"
+		fi
+		;;
+	esac
+done
-- 
cgit v1.2.3