aboutsummaryrefslogtreecommitdiff
path: root/dotfiles/.config/nsxiv
diff options
context:
space:
mode:
authorYaroslav de la Peña Smirnov <yps@yaroslavps.com>2021-12-21 01:52:47 +0300
committerYaroslav de la Peña Smirnov <yps@yaroslavps.com>2021-12-21 01:52:47 +0300
commitbdce2cfb10a204042a35cf574669cb46950e679f (patch)
tree88c1694b469dd6d69fd37a45bc3d1047c9b489eb /dotfiles/.config/nsxiv
parent8ee1282b5e364f7fa19f0631489b1f74b7525a95 (diff)
downloadswayrice-bdce2cfb10a204042a35cf574669cb46950e679f.tar.gz
swayrice-bdce2cfb10a204042a35cf574669cb46950e679f.zip
Switch to nsxiv as main image viewer
sxiv is no longer maintained.
Diffstat (limited to 'dotfiles/.config/nsxiv')
-rwxr-xr-xdotfiles/.config/nsxiv/exec/key-handler55
1 files changed, 55 insertions, 0 deletions
diff --git a/dotfiles/.config/nsxiv/exec/key-handler b/dotfiles/.config/nsxiv/exec/key-handler
new file mode 100755
index 0000000..f20a143
--- /dev/null
+++ b/dotfiles/.config/nsxiv/exec/key-handler
@@ -0,0 +1,55 @@
+#!/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
+}
+
+if [ "$1" = "t" ]; then
+ while read file; do
+ files="$(printf "%s\n%s" "$files" "$file")"
+ done
+ dragon-drag-and-drop -a $files
+ exit 0
+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-r")
+ # 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
+ exit ;;
+ "C-comma") rotate 270 $file ;;
+ "C-period") rotate 90 $file ;;
+ "C-slash") rotate 180 $file ;;
+ esac
+done