Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request] Run command on image copy #176

Open
jerbaroo opened this issue Jun 15, 2024 · 9 comments
Open

[Feature request] Run command on image copy #176

jerbaroo opened this issue Jun 15, 2024 · 9 comments

Comments

@jerbaroo
Copy link

Similar to #119 but providing a command to be run on image copy rather than image save, either via config file or via CLI args.

This would allow emitting a notification if I have copied to clipboard. This would be nice in combination with #119, to have different notifications in the two different success scenarios.

Example: swappy --on-copy 'notify-send "Copied to clipboard"' ...

@jerbaroo
Copy link
Author

Ability to have some kind of feedback on image copy/save would be a positive improvement to UX.

@ghost
Copy link

ghost commented Jul 10, 2024

I was looking for something like this too. This is the solution I came up with: my swappy script.

Edit- I just realized you were looking for a copy-to-clipboard notification. This script notifies of file saves and overwrites the filename with a timestamp. I'm sure a clipboard notification could be included. I'll do some research on that and see what I can come up with.

@markstos
Copy link

@jerbaroo It's already possible to chain another action using Unix pipes, as Swappy can already send the image to STDOUT when "save" is used. The receiving app or script needs to be able to listen for input on STDIN and wait for it to arrive. wl-copy can already do this:

swappy -f unsplash-slow.jpg --output-file - | wl-copy

@jerbaroo
Copy link
Author

@markstos can that approach distinguish between the user actions of saving to file vs copying to clipboard?

@markstos
Copy link

@jerbaroo You can pipes to both save to a file or copy a clipboard, if that's what you mean. You could start swappy either way:

# copy to clipboard
swappy -f in.jpg --output-file - | wl-copy

# write to file.
swappy -f in.jpg --output-file - >/path/to/file.jpg

The reason to not give a path directly to --output-file is that it will write that file into the an output directory.

Another thing you can do to get feedback that you've saved or copied the file is to enable early_exit=true in the config file. With that enabled, the feedback that you will get is that the application window will close. For me that's great-- that's what I want to do after a copy or save.

@jerbaroo
Copy link
Author

jerbaroo commented Dec 16, 2024

@markstos I want to know which of the two buttons on the top right (save or copy) were clicked by the user

@jerbaroo
Copy link
Author

jerbaroo commented Dec 16, 2024

If user clicks the copy button I want to be able to send a notification to the user "Image copied to clipboard" and if they click the save to file button I will send the notification "Image saved to <path>"

@markstos
Copy link

If you choose one workflow or the other, then you can you have that now, without waiting for someone to code up another solution.

For example:

swappy -f in.jpg -o - >/path/to/file.jpg && notify-send "saved to /path/to/file.jpg"

@jerbaroo
Copy link
Author

I specifically want to be able to send a notification based on what action the user took (past tense). Your solution afaict is assuming what the user will do before swappy has been opened.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants