From 9b6a8eb73df962faf29572af22278c3af7cba159 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yaroslav=20de=20la=20Pe=C3=B1a=20Smirnov?= Date: Mon, 14 Dec 2020 00:37:20 +0300 Subject: sxiv: shorcut to rotate images Taken and modified from the example script included with sxiv. --- dotfiles/.config/sxiv/exec/key-handler | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/dotfiles/.config/sxiv/exec/key-handler b/dotfiles/.config/sxiv/exec/key-handler index 8fa1bdb..d9bad9f 100755 --- a/dotfiles/.config/sxiv/exec/key-handler +++ b/dotfiles/.config/sxiv/exec/key-handler @@ -1,5 +1,14 @@ #!/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 +} + while read file; do case "$1" in "C-a" | "C-1") @@ -31,5 +40,8 @@ while read file; do mv $(dirname "$dir")/"$base".NEF ~/etc/temp/trash/ fi exit ;; + "C-comma") rotate 270 $file ;; + "C-period") rotate 90 $file ;; + "C-slash") rotate 180 $file ;; esac done -- cgit v1.2.3