pqiv
pqiv copied to clipboard
Use Command Output as Action Parameter
Is there a mechanism to use the output of a bash command as input for a subsequent action?
For instance, I would want to bind a key to do some small bash calculation based on the current image name and then jump n images forward, where n is the output of the bash calculation, e.g. something like:
pqiv --bind-key 'f { command(echo $1 && n=5); goto_file_relative($n)) }' .
Implementation is quite straightforward, see read_commands_thread for how to schedule a bunch of commands, and apply_external_image_filter for how commands are run. We'd have to add a new prefix, e.g. "@", and make that behave like a combination of the pipe (|) and plain command: Pass the filename as a parameter, connect a pipe to stdout of the process, read it from another thread and process it as actions.
I'd for simplicity not allow to define variables like that, just require that the script outputs the full commands.