Krolyxon
Commit eaf55e9

Branches

Refs →

nsxiveaf55e9

Added actions for tag addition & removal to key-handler

Author
Bert Münnich
Date
2014-08-20 11:34 +0200
Parent
3a68017
Commit
eaf55e9af967a6840234267a6df9bbb225f2c2d2

+20 −1

2 files changed

  1. M Makefile +1 −1
  2. M exec/key-handler +19 −0
M Makefile View
@@ -1,4 +1,4 @@
1−VERSION = git-20140818
1+VERSION = git-20140820
22
33 PREFIX = /usr/local
44 MANPREFIX = $(PREFIX)/share/man
M exec/key-handler View
@@ -11,6 +11,8 @@
1111 # where C/M/S indicate Ctrl/Meta(Alt)/Shift modifier states and KEY is the X
1212 # keysym as listed in /usr/include/X11/keysymdef.h without the "XK_" prefix.
1313
14+readonly TAGFILE="$HOME/.config/sxiv/tags"
15+
1416 rotate() {
1517 case "$(file -b -i "$2")" in
1618 image/jpeg*) jpegtran -rotate "$1" -copy all -outfile "$2" "$2" ;;
@@ -18,6 +20,21 @@ rotate() {
1820 esac
1921 }
2022
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+
2138 key="$1"
2239 shift
2340
@@ -28,5 +45,7 @@ case "$key" in
2845 "C-comma") for file in "$@"; do rotate 270 "$file"; done ;;
2946 "C-period") for file in "$@"; do rotate 90 "$file"; done ;;
3047 "C-slash") for file in "$@"; do rotate 180 "$file"; done ;;
48+"C-t") tag_add "$@" ;;
49+"M-T") tag_del "$@" ;;
3150 esac
3251