jtheoof/swappy

--output-file is surprising

ThinkChaos opened this issue · 10 comments

Hi,

I find the behaviour of --output-file quite surprising: usually tools use that file to save/output anything.
Swappy instead uses the save dir by default, and only at the end writes to that file.
I'd like Swappy to not create a new file every time I click save, instead of just overwriting the same file again and again.

How do you feel about changing -o's behavior to match what most applications do?
If changing it is out of the question, maybe we can add another option to opt out of the extra files?

I could make a PR, just want to ask what's your thoughts first.

I'm have trouble to understand.

I'd like Swappy to not create a new file every time I click save, instead of just overwriting the same file again and again.

What does this mean? Can you clarify the use case?

When I make a screen shot, it automatically opens in Swappy.
Then when I edit it, and click save, it creates a file in my home directory (the default save dir). I often click save/ctrl-s a bunch of times, and end up with a bunch of files in there.

I tried changing my setup to use -o so I only ever get a single file, even if pressing save a lot. But that's not what it does.
I'd like it to also prevent writing the intermediate saves. Or at least have a different way to do so.

The goal of the -o option is properly stated in the man page and works as expected.

Print the final surface to when exiting the application.`

Perhaps you can try to tweak the value of save_filename_format=swappy.png in the config file to achieve what you want. Besides that I would prefer to keep the current behavior.

Yeah I understand it's documented well, I just think it goes against the general meaning of -o in other tools, which is why I called it surprising. I'm fine with not changing this.

How I use Swappy is I have a script that takes a screenshot and saves it in a timestamped file. Then it runs Swappy on that file.
I'd like Swappy to just act as an editor of that file, i.e. never write anything else than it.

A static config with save_filename_format could work if my script then moved that static file to where I want. But that's pretty hacky IMO and doesn't support multiple instances at the same time.
I guess if there was a --config flag to tell Swappy where to read the config, I could use that to generate a config per run with both save_filename_format and save_dir set.
Is that something you'd be interested in merging?

EDIT: My other suggestion was adding something like --no-snapshots, and change the save to always write to -o. What do you think of that?

I'm not really opposed to change the -o option to match the use case you describe. I think it makes sense even though that would be a breaking change.
Having a --config would be good as well.

When I make a screen shot, it automatically opens in Swappy. Then when I edit it, and click save, it creates a file in my home directory (the default save dir). I often click save/ctrl-s a bunch of times, and end up with a bunch of files in there.

Using the time when the image was opened in the file name format rather then the time when the file if save would fix that.

The current behavior is that swappy will change the file name for the same image every time it's being saved.

Maybe a config like file-format-time=[when-save|when-open] could be used.

Hi, I have a problem related to the -o option. I wanted to save the file to the exact location. In this example, I want to save it to $HOME/Pictures/itworks.png, but it always saves to the default save_dir instead of the option I provided. Here's what I did:

grim -g "$(slurp)" - | swappy --output-file "$HOME/Pictures/itworks.png" -f - 

What is the proper way to achieve this?

but it always saves to the default save_dir instead of the option I provided.

I am having the same problem, but I think that is because the -o option does not actually refer to a save location. It seems to be meant to used to overwrite the contents of a specific pre-existing file.

I am having the same problem, but I think that is because the -o option does not actually refer to a save location. It seems to be meant to used to overwrite the contents of a specific pre-existing file.

Maybe it would be possible to add an additional option for swappy to save output at a given file path that would override the config save_dir and save_filename_format?