jtheoof/swappy

Autoclosing the image preview after copying image to clipboard.

Z-xus opened this issue ยท 7 comments

Z-xus commented

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

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.

@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?

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 -```

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.

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?

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".

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