Take area screenshot without saving in disk in gnome-screenshot

How do I take a area selected screenshot and have it in clipboard without saving it in disk? I couldn't find a way to do this in Zorin OS 17 (wayland). I used to do this in zorin 16 (x11).
As a developer, this feature is very useful cause we have so show stuff quickly and we don't want to fill our disk.

Hi, welcome to the Zorin OS community!

The short answer is you cannot, at least not using the default method used by Zorin OS 17. The reason is not due to X11 nor Wayland, it has to do with how the new screenshot functionality works, as it's now embedded into the desktop environment whereas before it was a stand alone application. Unfortunately, the new screenshot tool doesn't have an option to send the image to the clipboard.

However, you can install the old gnome-screenshot utility and use it just the same as you did in Zorin OS 16. You can search for it in the Software Store, or install through the command line with:

sudo apt install gnome-screenshot -i

You'll probably want use that as the default, for which you'll need to go into the Settings -> Keyboards -> View and Customize Shortcuts -> Custom Shortcuts, and set it to launch this instead:

Note the warning, saying that it'll replace that keyboard shortcut that is currently being taken by the built-in tool. Also note, in the screenshot I forgot to add the -i for interactive: the command should be: gnome-screenshot -i.

1 Like

I must point out that X11 and Wayland are involved.
The reason Gnome switched to their shell integrated screenshot tool was due to the need for Wayland Compatibility.

If the member is going to install the old screenshot tool, they should also switch back to using X11.

It seems to be working fine for me under Wayland: I can take a screenshot and paste it right away on something like Gimp. Maybe is because of some specific edge case? Taking a screenshot of the entire screen and from individual windows seems to work fine for me.

you can do it with ksnip
under settings you can set to "automatically copy new captures to clipboard" , and not save it.
not sure if ksnip works with wayland, i'm on x11
you could try yea?

edit: seems it works in gnome-wayland

After a lot of research, it's obvious that there's no way to take a screenshot to clipboard without saving it (no matter what I use). But i found this line of code which works perfectly (22.04 - I do NOT want screenshots to be saved to file - Ask Ubuntu). I just had to set this command in a custom keyboard shortcut.

bash -c "gnome-screenshot -af ~/Pictures/Screenshots/_custom_screenshot && xclip ~/Pictures/Screenshots/_custom_screenshot -selection clipboard -target image/png; rm ~/Pictures/Screenshots/_custom_screenshot

Before I posted I tested it with ksnip , I could take screenshots and it copied to my clipboard , but didn't save the screenshot anywhere.
Just saying :smiley:
But glad you were able to come right another way :+1:

2 Likes

Well as you all know by now, my favourite screenshot tool is Spectacle, but works best in Plasma. Why Spectacle? Well I used kde (neonuser) to create the Unofficial Manual for Zorin 17, especially for taking area screenshots one after the other, the beauty of Spectacle is it remembers your last area dimensions which was great for taking inages of the Zorin 17 VM images needed for the manual.

That will technically work, as it ultimately accomplishes what you're after. However, it's doing so in a very wasteful way. The better way to do this is:

gnome-screenshot -ac

This simply takes the screenshot of the area selected and saves it directly to the clipboard, whereas the snippet you copied first saves it to the disk, copies that file to the clipboard, and deletes the file.

In my previous snippet I used the -i option for --interactive which would ask you what would you like to do: take the whole screen, a particular window or just an area, and then you have the option to save to the clipboard or to a file.
Obviously, I misunderstood that you were trying to directly select an area instead of being prompted for options.

You can see what gnome-screenshot can do by running gnome-screenshot --help in the terminal.

2 Likes

gnome-screenshot -ac does not work in my pc. IDK why... Other options you mentioned "-i" works, but it's kinda slow. I have to click & select a lot. I just wanted a way that works with just 1 click of shortcut.

I think I spoke too soon, as I only looked at the options available without testing them...

So, with the interactive window, I can copy the screenshot to the clipboard without issues. However, the command line option -c or --clipboard doesn't seem to work at all. Looking a bit more into it, it seems this has been an ongoing issue since Ubuntu 18.04, and it's likely not going to be addressed at this point since Gnome has moved forward with their new implementation.

In that case, I have to agree that the snippet of code you used is the best (and only?) choice to mimic the behavior that you're after. But I still would like to offer an alternative to improve upon that a little bit:

- bash -c "gnome-screenshot -af ~/Pictures/Screenshots/_custom_screenshot && xclip ~/Pictures/Screenshots/_custom_screenshot -selection clipboard -target image/png; rm ~/Pictures/Screenshots/_custom_screenshot
+ bash -c 'gnome-screenshot -af "$XDG_RUNTIME_DIR"/_custom_screenshot && xclip "$XDG_RUNTIME_DIR"/_custom_screenshot -selection clipboard -target image/png; rm "$XDG_RUNTIME_DIR"/_custom_screenshot'

The $XDG_RUNTIME_DIR is a special directory that exists only in RAM. This will be faster — admittedly, for such a simple operation there's not a lot of room for noticeable improvement — but more importantly it won't write anything to disk.

1 Like

Thanks a lot. Can't be a better solution than this. I added this solution on askUbuntu too.

1 Like