A Simple X Image Viewer
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 
 
 

53 líneas
1.6 KiB

  1. #!/bin/sh
  2. # Example for $XDG_CONFIG_HOME/sxiv/exec/key-handler
  3. # Called by sxiv(1) after the external prefix key (C-x by default) is pressed.
  4. # The next key combo is passed as its first argument, followed by the paths of
  5. # all marked images or the path of the current image, if no image is marked.
  6. # sxiv(1) blocks until this script terminates. It then checks which images
  7. # have been modified and reloads them.
  8. # The key combo argument has the following form: "[C-][M-][S-]KEY",
  9. # where C/M/S indicate Ctrl/Meta(Alt)/Shift modifier states and KEY is the X
  10. # keysym as listed in /usr/include/X11/keysymdef.h without the "XK_" prefix.
  11. readonly KEY="$1"; shift
  12. readonly TAGFILE="$HOME/.config/sxiv/tags"
  13. rotate() {
  14. degree="$1"; shift
  15. for file in "$@"; do
  16. case "$(file -b -i "$file")" in
  17. image/jpeg*) jpegtran -rotate "$degree" -copy all -outfile "$file" "$file" ;;
  18. *) mogrify -rotate "$degree" "$file" ;;
  19. esac
  20. done
  21. }
  22. tag_add() {
  23. >>"$TAGFILE"
  24. tags=$(dmenu <"$TAGFILE" | tr '\n' ',')
  25. [ -z "$tags" ] && return
  26. iptckwed -a "$tags" "$@"
  27. echo -n "$tags" | tr ',' '\n' | sort - "$TAGFILE" | uniq >"$TAGFILE.new"
  28. mv -f "$TAGFILE"{.new,}
  29. }
  30. tag_del() {
  31. tags=$(iptckwed -ql "$@" | cut -f 2 | tr ',' '\n' | sort | uniq | dmenu | tr '\n' ',')
  32. [ -z "$tags" ] && return
  33. iptckwed -r "$tags" "$@"
  34. }
  35. case "$KEY" in
  36. "C-c") echo -n "$@" | xsel -i ;;
  37. "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 ;;
  38. "C-g") gimp "$@" & ;;
  39. "C-comma") rotate 270 "$@" ;;
  40. "C-period") rotate 90 "$@" ;;
  41. "C-slash") rotate 180 "$@" ;;
  42. "C-t") tag_add "$@" ;;
  43. "M-T") tag_del "$@" ;;
  44. esac