summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBert Münnich <ber.t@posteo.de>2014-08-20 11:39:56 +0200
committerBert Münnich <ber.t@posteo.de>2014-08-20 11:39:56 +0200
commit75a665670a60d6b7f0ee31dd8bcccbb0bc22d9bc (patch)
tree8d8f0baac668e5f63043fa307198437505484fef
parenteaf55e9af967a6840234267a6df9bbb225f2c2d2 (diff)
downloadnsxiv-75a665670a60d6b7f0ee31dd8bcccbb0bc22d9bc.tar.zst
Refactored rotation in key-handler
-rw-r--r--exec/key-handler23
1 files changed, 12 insertions, 11 deletions
diff --git a/exec/key-handler b/exec/key-handler
index 12e82ab..0586dde 100644
--- a/exec/key-handler
+++ b/exec/key-handler
@@ -11,13 +11,17 @@
# 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.
+readonly KEY="$1"; shift
readonly TAGFILE="$HOME/.config/sxiv/tags"
rotate() {
- case "$(file -b -i "$2")" in
- image/jpeg*) jpegtran -rotate "$1" -copy all -outfile "$2" "$2" ;;
- *) mogrify -rotate "$1" "$2" ;;
- esac
+ degree="$1"; shift
+ for file in "$@"; do
+ case "$(file -b -i "$file")" in
+ image/jpeg*) jpegtran -rotate "$degree" -copy all -outfile "$file" "$file" ;;
+ *) mogrify -rotate "$degree" "$file" ;;
+ esac
+ done
}
tag_add() {
@@ -35,16 +39,13 @@ tag_del() {
iptckwed -r "$tags" "$@"
}
-key="$1"
-shift
-
-case "$key" in
+case "$KEY" in
"C-c") echo -n "$@" | xsel -i ;;
"C-e") for file in "$@"; do urxvt -bg "#444" -fg "#eee" -sl 0 -title "$file" -e sh -c "exiv2 pr -q -pa '$file' | less" & done ;;
"C-g") gimp "$@" & ;;
-"C-comma") for file in "$@"; do rotate 270 "$file"; done ;;
-"C-period") for file in "$@"; do rotate 90 "$file"; done ;;
-"C-slash") for file in "$@"; do rotate 180 "$file"; done ;;
+"C-comma") rotate 270 "$@" ;;
+"C-period") rotate 90 "$@" ;;
+"C-slash") rotate 180 "$@" ;;
"C-t") tag_add "$@" ;;
"M-T") tag_del "$@" ;;
esac