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.
 
 
 
 
 
 

57 líneas
1.7 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. The paths of all marked
  5. # images--or of the current image, if no image is marked--are passed via stdin,
  6. # one file path per line.
  7. # sxiv(1) blocks until this script terminates. It then checks which images
  8. # have been modified and reloads them.
  9. # The key combo argument has the following form: "[C-][M-][S-]KEY",
  10. # where C/M/S indicate Ctrl/Meta(Alt)/Shift modifier states and KEY is the X
  11. # keysym as listed in /usr/include/X11/keysymdef.h without the "XK_" prefix.
  12. readonly KEY="$1";
  13. readonly TAGFILE="$HOME/.config/sxiv/tags"
  14. readonly TMPFILE="/tmp/sxiv.$$"
  15. rotate() {
  16. degree="$1"
  17. while read file; do
  18. case "$(file -b -i "$file")" in
  19. image/jpeg*) jpegtran -rotate "$degree" -copy all -outfile "$file" "$file" ;;
  20. *) mogrify -rotate "$degree" "$file" ;;
  21. esac
  22. done
  23. }
  24. tag_add() {
  25. >>"$TAGFILE"
  26. tags=$(dmenu <"$TAGFILE" | tr '\n' ',')
  27. [ -z "$tags" ] && return
  28. iptckwed -i -a "$tags"
  29. echo -n "$tags" | tr ',' '\n' | sort - "$TAGFILE" | uniq >"$TAGFILE.new"
  30. mv -f "$TAGFILE"{.new,}
  31. }
  32. tag_del() {
  33. cat >"$TMPFILE"
  34. tags=$(iptckwed -iql <"$TMPFILE" | cut -f 2 | tr ',' '\n' | sort | uniq | dmenu | tr '\n' ',')
  35. [ -z "$tags" ] && return
  36. iptckwed -i -r "$tags" <"$TMPFILE"
  37. rm -f "$TMPFILE"
  38. }
  39. case "$KEY" in
  40. "C-c") tr '\n' ' ' | xsel -i ;;
  41. "C-e") while read file; do urxvt -bg "#444" -fg "#eee" -sl 0 -title "$file" -e sh -c "exiv2 pr -q -pa '$file' | less" & done ;;
  42. "C-g") tr '\n' '\0' | xargs -0 gimp & ;;
  43. "C-comma") rotate 270 ;;
  44. "C-period") rotate 90 ;;
  45. "C-slash") rotate 180 ;;
  46. "C-t") tag_add ;;
  47. "M-T") tag_del ;;
  48. esac