jtheoof / swappy

A Wayland native snapshot editing tool, inspired by Snappy on macOS
MIT License
1k stars 40 forks source link

Autoclosing the image preview after copying image to clipboard. #161

Closed Z-xus closed 5 months ago

Z-xus commented 8 months ago

Hello, I have been using swappy for a while, and my usual use case is to just copy a screenshot to clipboard and then use that image. Is there any workaround to close image preview automatically once I have copied the image? It's just for convinience, but means a lot to me. Thanks! image

Katzenkralle commented 8 months ago

I had the same issue where copying to clipboard, with autoclosing enabled, would not work. I fixed it by installing wl-clipboard. I wonder how it could work without it in the first place.

kadamski commented 6 months ago

@AsarNaufil did you try using "early_exit=true" option in the config file? See the information in the man page. Isn't that what you need?

eightballocto commented 5 months ago

Just for the heck of it, I'll share a script I made for screenshotting displays in sway. You'll probably have to modify it depending on how many displays you have. This script autocloses swappy after a given amount of time, depending on the positional parameter it's given at execution. I typically like to specify this number inside of the sway config, usually as 5 or 10.


#! /bin/bash

# Print screen of active workspace on the corresponding display

# Because we're sending this to swappy, let's add the convenience of when this screenshot was taken.
time=$(date +%D_%I:%M_%p)

# Ask swaymsg which display is "active"
# Also strip quotes.
display=$(swaymsg -rt get_workspaces | jq '.[] | select(.focused==true)' | jq .output | tr -d '"')

# Screenshot, also send to swappy. Swappy will "die" after a set amount of time, specified by the command argument.
grim -o $display - | wl-copy
grim -o $display - | timeout ${1}m swappy --name=GrimScreenshot_${time} -f -```
jtheoof commented 5 months ago

I'm not I understand the use case here. If it's just to copy content from the screen you don't need swappy at all.

Z-xus commented 5 months ago

I'm not I understand the use case here. If it's just to copy content from the screen you don't need swappy at all.

to copy screenshots taken?

kadamski commented 5 months ago

But swappy is all about editing the screenshot taken. Swappy doesn't make screenshots itself (that's what we usually use grim for). It also doesn't do the region selection (that's what we usually use slurp for).

If you do not want to add text/arrows/circles etc to the screenshot you take, swappy is not needed in your workflow. If, on the other hand, you do want to add some annotations then killing it from the outside script after a fixed amount of time doesn't make much sense anyways. Adding annotations is inherently interactive process and as such you never know how long it will take.

If to want to copy the image to clipboard, there's a button for that in swappy's window. You can co figure if swappy will be closed as soon as you click it or not.

It seems to me like this script is trying to (ab)use swappy as a "screenshot previewer".

Z-xus commented 5 months ago

I see.. I'll close the issue then. Thanks.