aboutsummaryrefslogtreecommitdiff
path: root/dotfiles/.config/nsxiv/exec/key-handler
blob: 773b6ee80cfdb66c0f9d02755746813bbb82d831 (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/sh

rotate() {
	degree="$1"
	file="$2"
	case "$(file -b -i "$file")" in
	image/jpeg*) jpegtran -rotate "$degree" -copy all -outfile "$file" "$file" ;;
	*)           mogrify  -rotate "$degree" "$file" ;;
	esac
}

action="$1"

if [ "$1" = "C-t" ]; then
	while read file; do
		files="$(printf "%s\n%s" "$files" "$file")"
	done
	dragon-drop -a $files
	exit 0
fi
if [ "$1" = "C-r" ]; then
	while read file; do
		# Move file to 'trash' directory, if the current directory's name is
		# JPEG, remove the NEF file as well
		dir="$(dirname "$file")"
		name="$(basename "$file")"
		base="${name%.*}"
		mv "$file" ~/.local/trash/
		if [ "JPEG" = "$(basename $dir)" ]; then
			mv $(dirname "$dir")/"$base".NEF ~/.local/trash/
		fi
	done
fi

while read file; do
	case "$1" in
		"C-a" | "C-1")
			setbg "$file"
			exit ;;
		"C-2")
			setbg "$file" "2"
			exit ;;
		"C-s")
			setbglblur "$file"
			exit ;;
		"C-d")
			setbglsimple "$file"
			exit ;;
		"C-c")
			wl-copy < "$file"
			exit ;;
		"C-f")
			wl-copy "$file"
			exit ;;
		"C-comma")  rotate 270 $file ;;
		"C-period") rotate  90 $file ;;
		"C-slash")  rotate 180 $file ;;
	esac
done