2

I used the 'keyboard' section in Cinnamon's Python System Settings application to create a custom shortcut that executes the command gnome-screenshot -a every time I press the Print Screen key. It does not work as expected. Instead of displaying the cross used to select the portion of the screen to take a screen shot of, the system makes a 'beeping' sound. gnome-screenshot gets executed, and outputs the following to stderr:

** Message: Unable to use GNOME Shell's builtin screenshot interface, resorting to fallback X11.

(gnome-screenshot:6577): Gdk-CRITICAL **: gdk_pixbuf_get_from_surface: assertion 'width > 0 && height > 0' failed

(gnome-screenshot:6577): Gtk-CRITICAL **: gtk_window_resize: assertion 'width > 0' failed

** (gnome-screenshot:6577): CRITICAL **: Unable to capture a screenshot of any window

Running it from a terminal emulator (virtual console would work if you set the $DISPLAY environment variable and others) works and gives expected results. Occasionally, after pressing the Print Screen key a good ~50 times it will work as expected. Changing the command ran when pressing the Print Screen key to gnome-screenshot -w works perfectly, but I need to be able to select a portion of the screen to take a screen shot of. This question has been asked here but has no answer (the OP settled with using gnome-screenshot -w after it being pointed out in the comments that it works). My situation is exactly the same of the OP of the linked post.

So what can I do so I don't have to excessively press the Print Screen key just to take a screen shot?

Billy
  • 615
  • 3
  • 11
  • 29
  • Same trouble ( work only fast triple press hotkey. you can install xfce4-screenshooter - "xfce4-screenshooter -rs ~/Pictures/" , but it can't store full screen without asking file name , like gnome - "gnome-screenshot -f ~/Pictures/fname.png" ( i use both . – Alexey Agapov Sep 04 '18 at 11:44
  • Did you make it work? I find that if I create a launcher to run the script works well, if I run it from the terminal works well, displaying a warning. But if I bind it to a keyboard shortcut doesn't work. – Guanaco Devs Jul 07 '19 at 07:05
  • https://github.com/linuxmint/cinnamon/issues/3981 has discussion of this issue. Instead of `gnome-screenshot`, I'm using `sh -c 'maim --select --highlight --color 1,.8,.1,.1 | xclip -selection clipboard -t image/png'` – raylu Feb 04 '20 at 23:53

2 Answers2

1

I have a similar situation, where I bind the system's screenshot shortcuts to my scripts, so when I invoke the shortcut gnome-screenshot will take the screenshot, save it to a file and then open it with Gimp.

#!/bin/bash    
SSFile=~/Images/screenshot_window.png
# This command takes a window screenshot and saves it to a file
gnome-screenshot -w -f $SSFile
flatpak run org.gimp.GIMP $SSFile

In order to grab an area, just replace -w with -a and prepend sleep 0.1 got it from here, so in my case the final script is:

#!/bin/bash    
SSFile=~/Images//screenshot_area.png
sleep 0.1
# Take a Screenshot from an area and saves it to a file
gnome-screenshot -a -f $SSFile
flatpak run org.gimp.GIMP $SSFile

Without the sleep 0.1 part works fine when run from the terminal, nemo or a custom launcher, but not with the keyboard shortcut.

Guanaco Devs
  • 211
  • 2
  • 7
-1

The command is correct.

gnome-screenshot -a -c

Avoid using the windows or super key, use association of free keys in the system.

phk
  • 5,893
  • 7
  • 41
  • 70
  • 1
    Still doesn't work, and when it does, it just copies the screenshot to the clipboard instead of writing it to a file, which is what I need. – Billy Apr 30 '17 at 14:01