maim icon indicating copy to clipboard operation
maim copied to clipboard

[Documentation] Scrot's -e flag Shortcomming in Maim

Open MimaHakurei opened this issue 6 years ago • 1 comments

Scrot contains the following command:

-e, --exec command Exec command on the saved image.

It's useful because it allows commands like these: scrot 'Snapshot_%Y_%m_%d_%H-%M-%S_$wx$h.png' -q 100 $1 -e 'xclip -se c -t image/png -i "$f"' Where the image is saved to a file and the resulting file is operated on (in this case copied to the clipboard).

In maim, one would need to capture the date beforehand and use it in two separate operations like so: filename=~/SomeDir/Snapshot_$(date +%Y_%m_%d_%N).png maim $1 $filename -q 100 && xclip -selection clipboard -t image/png -i $filename

While this solution is elegant in this case, it would be nice to have a native option for piping maim to multiple programs.

The tee program is a possibility, but it reduces the ability to use maim options. For example: If I want to save the image with predefined quality value, then there is no way to use tee with maim in a way that preserves this. The following line would not work for example since xclip refuses input that contains the -q flag. maim $1 -q 100 | tee ~/SomeDir/Snapshot_$(date +%Y_%m_%d_%N).png | xclip -selection clipboard -t image/png

I've been playing around with adapting maim in my scripts for a little bit so I'm interested to see if there's something I missed or if maim is intended to be used this way. Feel free to let me know if there's anything that wasn't clear.

MimaHakurei avatar Jun 04 '19 01:06 MimaHakurei

I feel like the exec command is over-engineering maim, you can just use your shell to do things to the image after it's taken.

Is it a bug with xclip to abort on commands that contain -q? You can try using the --quality=100 option instead if that's the case, or try changing the output format to jpeg.

naelstrof avatar Jun 04 '19 06:06 naelstrof