Refactored rotation in key-handler

This commit is contained in:
Bert Münnich 2014-08-20 11:39:56 +02:00
parent eaf55e9af9
commit 75a665670a

View file

@ -11,13 +11,17 @@
# where C/M/S indicate Ctrl/Meta(Alt)/Shift modifier states and KEY is the X # 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. # keysym as listed in /usr/include/X11/keysymdef.h without the "XK_" prefix.
readonly KEY="$1"; shift
readonly TAGFILE="$HOME/.config/sxiv/tags" readonly TAGFILE="$HOME/.config/sxiv/tags"
rotate() { rotate() {
case "$(file -b -i "$2")" in degree="$1"; shift
image/jpeg*) jpegtran -rotate "$1" -copy all -outfile "$2" "$2" ;; for file in "$@"; do
*) mogrify -rotate "$1" "$2" ;; case "$(file -b -i "$file")" in
esac image/jpeg*) jpegtran -rotate "$degree" -copy all -outfile "$file" "$file" ;;
*) mogrify -rotate "$degree" "$file" ;;
esac
done
} }
tag_add() { tag_add() {
@ -35,16 +39,13 @@ tag_del() {
iptckwed -r "$tags" "$@" iptckwed -r "$tags" "$@"
} }
key="$1" case "$KEY" in
shift
case "$key" in
"C-c") echo -n "$@" | xsel -i ;; "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-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-g") gimp "$@" & ;;
"C-comma") for file in "$@"; do rotate 270 "$file"; done ;; "C-comma") rotate 270 "$@" ;;
"C-period") for file in "$@"; do rotate 90 "$file"; done ;; "C-period") rotate 90 "$@" ;;
"C-slash") for file in "$@"; do rotate 180 "$file"; done ;; "C-slash") rotate 180 "$@" ;;
"C-t") tag_add "$@" ;; "C-t") tag_add "$@" ;;
"M-T") tag_del "$@" ;; "M-T") tag_del "$@" ;;
esac esac