nsxiveaf55e9
Added actions for tag addition & removal to key-handler
+20 −1
2 files changed
- M Makefile +1 −1
- M exec/key-handler +19 −0
| @@ -1,4 +1,4 @@ | |||
| 1 | − | VERSION = git-20140818 | |
| 1 | + | VERSION = git-20140820 | |
| 2 | 2 | ||
| 3 | 3 | PREFIX = /usr/local | |
| 4 | 4 | MANPREFIX = $(PREFIX)/share/man | |
| @@ -11,6 +11,8 @@ | |||
| 11 | 11 | # where C/M/S indicate Ctrl/Meta(Alt)/Shift modifier states and KEY is the X | |
| 12 | 12 | # keysym as listed in /usr/include/X11/keysymdef.h without the "XK_" prefix. | |
| 13 | 13 | ||
| 14 | + | readonly TAGFILE="$HOME/.config/sxiv/tags" | |
| 15 | + | ||
| 14 | 16 | rotate() { | |
| 15 | 17 | case "$(file -b -i "$2")" in | |
| 16 | 18 | image/jpeg*) jpegtran -rotate "$1" -copy all -outfile "$2" "$2" ;; | |
| @@ -18,6 +20,21 @@ rotate() { | |||
| 18 | 20 | esac | |
| 19 | 21 | } | |
| 20 | 22 | ||
| 23 | + | tag_add() { | |
| 24 | + | >>"$TAGFILE" | |
| 25 | + | tags=$(dmenu <"$TAGFILE" | tr '\n' ',') | |
| 26 | + | [ -z "$tags" ] && return | |
| 27 | + | iptckwed -a "$tags" "$@" | |
| 28 | + | echo -n "$tags" | tr ',' '\n' | sort - "$TAGFILE" | uniq >"$TAGFILE.new" | |
| 29 | + | mv -f "$TAGFILE"{.new,} | |
| 30 | + | } | |
| 31 | + | ||
| 32 | + | tag_del() { | |
| 33 | + | tags=$(iptckwed -ql "$@" | cut -f 2 | tr ',' '\n' | sort | uniq | dmenu | tr '\n' ',') | |
| 34 | + | [ -z "$tags" ] && return | |
| 35 | + | iptckwed -r "$tags" "$@" | |
| 36 | + | } | |
| 37 | + | ||
| 21 | 38 | key="$1" | |
| 22 | 39 | shift | |
| 23 | 40 | ||
| @@ -28,5 +45,7 @@ case "$key" in | |||
| 28 | 45 | "C-comma") for file in "$@"; do rotate 270 "$file"; done ;; | |
| 29 | 46 | "C-period") for file in "$@"; do rotate 90 "$file"; done ;; | |
| 30 | 47 | "C-slash") for file in "$@"; do rotate 180 "$file"; done ;; | |
| 48 | + | "C-t") tag_add "$@" ;; | |
| 49 | + | "M-T") tag_del "$@" ;; | |
| 31 | 50 | esac | |
| 32 | 51 | ||