sxiv

simple X image viewer
git clone git://git.suckless.org/sxiv
Log | Files | Refs | LICENSE

commit 75a665670a60d6b7f0ee31dd8bcccbb0bc22d9bc
parent eaf55e9af967a6840234267a6df9bbb225f2c2d2
Author: Bert M√ľnnich <ber.t@posteo.de>
Date:   Wed, 20 Aug 2014 11:39:56 +0200

Refactored rotation in key-handler

Diffstat:
exec/key-handler | 23++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)

diff --git 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