diff options
author | xyz <gky44px1999@gmail.com> | 2021-08-09 13:23:46 -0700 |
---|---|---|
committer | xyz <gky44px1999@gmail.com> | 2021-08-09 13:23:46 -0700 |
commit | 457131b0d3ee72ac8913299aafa6893f44dc59e3 (patch) | |
tree | 5c57f191777ca3523e3f450014e94d2d91fccca8 /.config | |
parent | 6d4d226991b0b1696f721f00d42f8a0b3b3db6c8 (diff) |
edit sxiv key-handler
Diffstat (limited to '.config')
-rwxr-xr-x | .config/sxiv/exec/key-handler | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/.config/sxiv/exec/key-handler b/.config/sxiv/exec/key-handler new file mode 100755 index 00000000..ef181a76 --- /dev/null +++ b/.config/sxiv/exec/key-handler @@ -0,0 +1,49 @@ +#!/bin/sh + +# Example for $XDG_CONFIG_HOME/sxiv/exec/key-handler +# Called by sxiv(1) after the external prefix key (C-x by default) is pressed. +# The next key combo is passed as its first argument. Passed via stdin are the +# images to act upon, one path per line: all marked images, if in thumbnail +# mode and at least one image has been marked, otherwise the current image. +# sxiv(1) blocks until this script terminates. It then checks which images +# have been modified and reloads them. + +# The key combo argument has the following form: "[C-][M-][S-]KEY", +# 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. + +# my dependency notes +# jpegtran is owned by libjpeg-turbo +# mogrify is owned by imagemagick +# exiv2 is owned by exiv2 +# rawtherapee is owned by rawtherapee + +rotate() { + tr '\n' '\0' | xargs -0 realpath | sort | uniq | while read file; do + case "$(file -b -i "$file")" in + image/jpeg*) jpegtran -rotate 90 -copy all -outfile "$file" "$file" ;; + *) mogrify -rotate 90 "$file" ;; + esac + done +} + +flip() { + tr '\n' '\0' | xargs -0 realpath | sort | uniq | while read file; do + case "$(file -b -i "$file")" in + image/jpeg*) jpegtran -flip vertical -copy all -outfile "$file" "$file" ;; + *) mogrify -flip "$file" ;; + esac + done +} + +case "$1" in + "c") tr '\n' '\0' | xargs -0 realpath | xsel -b ;; + "d") [ "$(promptd "delete?")" = "Yes" ] && tr '\n' '\0' | xargs -0 rm ;; + "e") while read file; do alacritty -e sh -c "exiv2 pr -q -pa '$file' | less" & done ;; + "f") flip ;; + "g") tr '\n' '\0' | xargs -0 setsid -f gimp ;; + "l") tr '\n' '\0' | xargs -0 realpath -z | xargs -0 ln -s -t "$HOME/pictures/wallpapers" ;; + "r") rotate ;; + "w") tr '\n' '\0' | xargs -0 xwallpaper --maximize ;; +esac + |