16

I just freshly installed Ubuntu 18.04 and downloaded the latest updates. I'm having trouble taking screenshots to clipboard using the built-in gnome-screenshot tool. The default keyboard shortcuts Ctrl+PrintScreen and Ctrl+Shift+PrintScreen don't appear to work (makes the shutter sound, but empty clipboard and nothing saved in Pictures folder either), and using gnome-screenshot -c in the terminal is similarly ineffective.

I've read that gnome-screenshot had clipboard issues with Wayland, but my understanding is that 18.04 defaults to Xorg. Checking my login settings, the default is "Ubuntu," with a secondary "Ubuntu on Wayland" option. I'm just using the default.

pomsky
  • 68,507
xenon
  • 161

8 Answers8

28

Not sure if this is related - in my case (fresh Ubuntu 19.10), gnome-screenshot -c would put the captured image to the clipboard, but somehow I can only paste it in certain applications (e.g. Gimp) while not in others (e.g. Chrome).

Found a workaround by (assigning to a shortcut) this:

gnome-screenshot -acf /tmp/test && cat /tmp/test | xclip -i -selection clipboard -target image/png
Ferrard
  • 381
  • 1
    Nice workaround. Mine was working fine with Ubuntu 18.04 and when I recently upgraded to 20.04 it stopped working. Thanks for this solution. – raddevus Oct 08 '20 at 15:17
  • 10
    To make this work with Ubuntu 20.04 Keyboard Shortcuts I had to wrap it sh -c "gnome-screenshot -acf /tmp/test && cat /tmp/test | xclip -i -selection clipboard -target image/png" – Brian Leishman Apr 12 '21 at 16:01
  • 1
    The above answer for Ubuntu 20.04/.10 is the only one that worked for me. Thank you. – mattdlockyer Oct 17 '21 at 17:54
  • I expanded the command to clean up the image from the tmp folder sh -c "gnome-screenshot -af /tmp/clipboard-img.png && xclip -i -selection clipboard -target image/png /tmp/clipboard-img.png && rm /tmp/clipboard-img.png" – mercutio May 02 '22 at 08:30
  • 5
    I noticed that this actually seems to work just as gnome-screenshot -acf /tmp/test. I.e. just persisting to file seems to allow it to paste into apps like Chrome. This was a complete fluke, because I simply don't have xclip installed, but it still worked! – c24w Jul 08 '22 at 09:50
  • There is a similar solution for xfce4-screenshooter in xfce. It uses /dev/stdout to avoid the leak to /tmp. https://unix.stackexchange.com/questions/466278/xfce-screenshooter-and-clipboard-manager – poleguy Jun 14 '23 at 18:13
  • Btw it needs to be a real file. gnome-screenshot -acf /dev/null will not work. Too bad... – User9123 Aug 15 '23 at 19:30
10

I had the same problem in Ubuntu 20.04: gnome-screenshot -a -c was not copying to clipboard.

The solution was to ensure xclip was installed with:

sudo apt install xclip
  • gnome-screenshot version = 3.36.0
  • xclip version = 0.13-1
Ben
  • 101
2

My workaround is (for Ubuntu 2204, GNOME 42): Switching from wayland to xorg and made a custom keyboard shortcut with the following command: gnome-screenshot -a -c --file=/tmp/screenshot_tmp.png

Someone
  • 21
1

Today I had a similar problem under Oracle Linux 8: It wouldn't copy to the clipboard. I could resolve this with running the command:

env GDK_BACKEND=x11 gnome-screenshot -i

Note the x, it is not capital X as usual!

You may enter -c instead of -i, of course. On this Oracle Linux 8 machine other applications couldn't create a window at all without the GDK_BACKEND setting.

1

You have to use Ctrl+Alt+PrintScreen instead of Alt+PrintScreen.

  • This worked for me. It's also captured in the help section of the default Screenshot app.

    PS: I'm running Ubuntu 20.04.

    – bit-pirate Feb 01 '24 at 11:39
0

I had this problem on Ubuntu 20.04 but I couldn't get it working from a custom shortcut key. I had to write a bash script.

Note: I also had to install xclip as shown in Ben's answer.

Here it is:

  1. Run:

    nano screengrab.sh
    
  2. Add the following text:

    rm -rf /home/user/Pictures/2.png 
    gnome-screenshot -acf /home/user/Pictures/2.png
    

    Note: Your PNG file can be named anything, just make sure you delete the same named file first and then it will be created each time by the gnome-screenshot app. If you don't delete it or you have the wrong file name each time, it will fail silently.

  3. Save the file by pressing Ctrl+O followed by Ctrl+X.

  4. Make the script executable:

    chmod a+x screengrab.sh
    
  5. Open Settings → Keyboard and add a new shortcut with the details shown in the image below:

    shortcut keys

raddevus
  • 1,800
0

For people running a Wayland session, binding the following to a shortcut should work

gnome-screenshot -af /tmp/tmp_screenshot.png && wl-copy -ot image/png < /tmp/tmp_screenshot.png

Same principle as Ferrard is using really, just adapted for Wayland.

You need to have wl-clipboard installed.

Also, you might have to put this in a script and call that (I did, because my machine does not seem to like executing multiple commands in one shortcut, YMMV though).

Fynn
  • 338
-1

Try find $HOME -name "Screenshot*" to see if the screenshots are being saved in an unexpected location. Also check Settings|Keyboard Shortcuts. In a recently upgraded 20.04.1 (from 18.04) gnome-screenshot saved the png images in $HOME instead $HOME/Pictures as before.

  • As OP says in the title, the problem is not a file-system location but that the data doesnt end up on the clipboard – delf Nov 04 '21 at 15:10