aboutsummaryrefslogtreecommitdiffstats
path: root/.config/sxiv/exec/key-handler
blob: 9eed7d30077b2d2cd543c8a0bf79bc2d552de678 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/zsh

# The key combo argument has the following form: "[C-][M-][S-]KEY",
# 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.

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