19

I am trying to configure the 22.04 (Gnome 42) keyboard shortcut to get the "old" functionality of taking screenshots of area selections and pasting them into clipboard (Ctrl-Shft-PrtScr + select/release: done). The problem is that $ gnome-screenshot -ac doesn't copy the selection into clipboard unless there is an instance of gnome-screenshot utility running. Does anyone know how to work around this issue? (I know it is possible to run the "new" interactive screenshot tool, but that takes too many clicks and is not what I want.)

4
  • Just use the print button PrtScrn see here
    – Paul
    Jun 8 at 11:14
  • 1
    @Paul As mentioned in the question, this is not the functionality that I wanted, as it takes too many clicks to achieve the desired effect
    – Iiro Ullin
    Jun 8 at 15:41
  • @Iiro_Ullin It takes one click more than previously
    – Paul
    Jun 8 at 16:15
  • @Paul Yes and that is already too much. Yet it becomes worse, if the "new" and the "old" selections overlap: then you must move the old selection before you can make the new selection. Anyways, my clicking preferences are not a matter of discussion here: the discussion is about how to fix/work around the clipboard bug in gnome-screenshot
    – Iiro Ullin
    Jun 8 at 16:40

3 Answers 3

10

After installing Ubuntu 22.04

after you log out or restart the computer, the old gnome-screenshot is removed, so you need to reinstall it to make the old command to work.

sudo apt install gnome-screenshot

in gnome 42 the default shortcuts for using the screenshots are:

  1. Shift+Print takes a screenshot
  2. Print take a screenshot interactively
  3. Alt+Print take a screenshot of a window
  4. Shift+Ctrl+Alt+R record a screencast interactively

When you press ALT+PRINT throws a message

  • you can paste the image from the clipboard

settings for change keyboard in GUI are:
settings -> keyboard -> keyboard shortcuts -> Screenshots

TO ADD A CUSTOM SHORTCUTS

settings -> keyboard -> keyboard shortcuts -> custom shortcuts

  1. Custom shortcuts is at the end of list
gnome-screenshot -c -a

enter image description here

2
  • 3
    Well, that was exactly my point: this doesn't work for me. When you press the shortcut key combo, it makes the sound and all that, but doesn't actually copy anything into clipboard (unless there is an instance of gnome-screenshot already running). Did you verify that it actually works, not just makes a sound?
    – Iiro Ullin
    May 8 at 21:14
  • Same issue. I followed you, but it doesn't make anything rather than just making a sound. Did it work for all the guys who upvoted? Your response would be a great help.
    – Vam
    Jul 4 at 17:35
8

The -c command to copy the screenshot to the clipboard has a weird bug that doesn't copy the image when using -a to grab a selection.

A way to fix this is to make the command save the screenshot by adding --file={/filepath/filename.png} after the -a -c.

The command all together is gnome-screenshot -a -c --file={/filepath/filename.png}.

I don't know why this fixes the bug but it definitely works so you can try that.

Hope this is what you wanted @Iiro Ullin. Good luck!

9
  • Are you sure it's not copying the image? when I set the command to be gnome-screenshot -a -c --file=/home/betzalel-maor/Desktop/Screenshot001.png I can paste the screenshot! In my answer I wrote -c before -a, so change it to -a -c and it should work. Hope that helped and good luck! May 21 at 19:01
  • -c -a or -a -c or -ac etc, makes no difference -- it all does the same thing, however saving to a file does indeed fix the clipboard issue and can be used as a workaround. There's some clipboard bug that's been around for years and it seems to persist in this iteration of Gnome as well. I'll accept your answer if you reformulate it a bit to emphasize that that saving to a file somehow fixes the clipboard bug.
    – Iiro Ullin
    May 21 at 23:04
  • What do you mean, you want me to write another answer that will say just to save the screenshot and it should fix the bug? May 22 at 18:51
  • The important piece in your answer is that saving the screenshot in a file with --file=... somehow fixes the clipboard issue. Everything else is either irrelevant or is already present in the question. If you edit your answer to get rid of all that filler, I'd be happy to accept it (or I can just type your fix into my original question and refer to your response).
    – Iiro Ullin
    May 24 at 18:00
  • 2
    Sadly this solution didn't seem to reliably work for me, but it gave me an Idea of how to tackle the problem. I ended up saving the screenshot to a file and then manually adding it to the clipboard: sh -c "gnome-screenshot -a --file=screenshot.png; xclip -selection clipboard -t image/png -i screenshot.png"
    – A. P
    Jun 15 at 22:55
0

So this is what I did on my Ubuntu 22.04

Note this is for capturing an area onto the clipboard.

Install Gnome Screenshot: sudo apt install gnome-screenshot

Make sure that Xclip is installed. To install :

sudo apt install xclip

Create a custom keyboard shortcut. I used Ctrl + shift + Print Screen with command as: sh -c "gnome-screenshot -acf /tmp/test && cat /tmp/test | xclip -i -selection clipboard -target image/png".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.