13

Older versions of Ubuntu allowed us to use Ctrl+Shift+Print screen to prompt the selection of an area and take the screenshot by copying it directly to clipboard.

So, how do we get this back?

I want to stress that the undesirable behaviors of the current screenshot tool are:

  • Having to do an extra click after selecting the area in order to save the screenshot.
  • The image getting saved to a folder in addition to just being copied to the clipboard.

Additionally, how to change the default folder for the screenshots? dconf-editor does nothing for the new tool.


I tried installing gnome-screenshot and setting a custom shortcut with the command:

gnome-screenshot -a -c

It does allow me to select an area, but it does not save it to the clipboard afterwards.

Eduardo
  • 1,113
  • please [edit] your question to explain what you mean by dconf-editor does nothing. I have successfully used it as outlined in this answer – graham Apr 26 '22 at 13:56
  • gnome-screenshot is not the default tool for 22.04, dconf-editor works if you install and use it (and I would gladly do so) but it does not solve my main issues as I pointed out. In fact the answer you linked clearly did not solve the problem for the OP by reading his comments. – Eduardo Apr 26 '22 at 14:23
  • I'm not sure it matters what is the "default" tool or not. I think one of the beauties of Linux / Ubuntu is the ability for us to choose what we like. As for your problem, it's a bit strange to me. I've just upgraded to 22.04 and the feature that you want "back" is what I now have as default! I actually want what you now have and it seems like it is just the gnome-screenshot program. So, I just need to map my PrtScn key to gnome-screenshot. (Sorry, I can't solve your problem. I don't know how I got what you want; it just happened after my upgrade.) – Ray Apr 26 '22 at 14:30
  • @Eduardo that said, he accepted the answer in any event... – graham Apr 26 '22 at 14:35
  • Try the wrapper script around gnome-screenshot mentioned in this comment on the bug report about this problem – muru Apr 26 '22 at 15:43
  • @muru the wrapper did work, good to know it is an open issue in the gnome project itself, hopefully it goes somewhere. Do you want to answer this question so I can accept it? – Eduardo Apr 26 '22 at 16:29

1 Answers1

7

As muru pointed out in the comments this is an open issue in the gnome project and there is a workaround.

Here is how I solved it:

  1. Install gnome-screenshot:

    sudo apt install gnome-screenshot
    
  2. Install xclip:

    sudo apt install xclip
    
  3. Create the following script:

    #!/bin/bash  
    TMPFILE=`mktemp -u /tmp/screenshotclip.XXXXXXXX.png`  
    gnome-screenshot -af $TMPFILE && xclip $TMPFILE -selection clipboard -target image/png; rm $TMPFILE || echo "" 
    
  4. Save it wherever you want.

  5. Go to Settings → KeyboardView and Customize ShortcutsCustom Shortcuts.

  6. Add it as shown in the following image:

enter image description here


Now for saving the screenshot to a specific folder, I couldn't find a solution for the default GNOME tool, but if you are going to use gnome-screenshot anyway, an option is to create another custom shortcut for printing with gnome-screenshot, with a command like this:

sh -c 'gnome-screenshot -af /path/you/want/it/saved/$(date "+%Y.%m.%d-%H.%M.%S").png'
Eduardo
  • 1,113
  • That script gives me the error Screenshot.sh: 3: /tmp/screenshotclip.NoqDlClS.png: not found Missing argument for -f rm: missing operand on Ubuntu 22.04 – Foxes May 05 '22 at 19:13
  • @Foxes - the code should be ```#!/bin/bash

    TMPFILE=mktemp -u /tmp/screenshotclip.XXXXXXXX.png

    gnome-screenshot -af $TMPFILE && xclip $TMPFILE -selection clipboard -target image/png; rm $TMPFILE || echo ""

    
    
    – nyx69 May 10 '22 at 20:08