pqiv icon indicating copy to clipboard operation
pqiv copied to clipboard

calling external handlers for special files

Open bittorf opened this issue 4 years ago • 4 comments

i'am not happy with the way animations are working.

i see, that we can hack a little bit to work around this issue: https://github.com/phillipberndt/pqiv/issues/100#issuecomment-320435115 (but it is useless in montage-mode, is'nt it?)

what about something like:

pqiv \
    --mimetype 'video/mp4'  \
    --mimehandler 'mpv' \
    --mimetype 'audio/mpeg'  \
    --mimehandler 'mpg123' \
        "my_dir"

bittorf avatar Jan 12 '20 20:01 bittorf

Except for in montage mode, you can do this already by rebinding the keys to navigate images to also execute an external command.

In montage mode I don't see an easy way to do this right now, even conceptually.

phillipberndt avatar Jan 15 '20 07:01 phillipberndt

after thinking a bit about an elegant solution, this is my proposal:

we introduce an argument like this:

pqiv --checkcommand '/usr/local/bin/mycheck.sh'

This command takes the argument 'check' and the filename and is called for each file (image or video), just before it is opened.

It returns 0 (ok, use pqiv's internal capabilies) or not 0. In case of not 0, pqiv should open a black image and calls the command again with argument 'show' and the filename.

that's it.

a naive implementation would be:

#!/bin/sh
ACTION="$1"
FILE="$2"

case "$ACTION" in
  check)
    case "$(file -b --mime-type "$FILE" )" in
      video/*)
        false
      ;;
      *)
        true
      ;;
    esac
  ;;
  show)
    mpv "$FILE"
  ;;
esac

This should made the code in pqiv simple.

bittorf avatar Feb 07 '20 19:02 bittorf

Finally got time to get back to this.. this won't help. In montage mode, pqiv renders out all images over time. You'd have tons of mpv windows popping up if this was applied to the thumbnails in montage mode. Outside montage mode (i.e. after selecting a file within) the approach from the other issue would still work.

phillipberndt avatar Apr 11 '20 12:04 phillipberndt

When running in "montage mode", we can simply have another ACTION, e.g. check, show and render!?

bittorf avatar May 09 '20 11:05 bittorf