0

Is it possible to make gnome-screenshot save the image automatically without showing the confirmation dialog window?

I make a lot of screenshots and it would be convenient if I did not have to confirm at every occasion.

0

1 Answer 1

3

You can use the following command in the terminal:

gnome-screenshot -p -w -d 10 -f ~/Desktop/Screenshots/$(date +%Y%m%d%H%M%S).png

man gnome-screenshot tells us that

  • -p includes the mouse pointer
  • -w limits the region to the active window
  • -d is used to add a time delay (in seconds) and that's useful if you want to capture stuff like drop-down menus.
  • -f specifies the path and filename. I've provided a filename that incorporates a "time-stamp".

Note: if you want to select a particular area, use -a (for area):

gnome-screenshot -a -f ~/Desktop/Screenshots/$(date +%Y%m%d%H%M%S).png

The cursor changes to cross-hairs. Drag diagonally across the desired area. You can't use -d when using -a.

You can also make a keyboard shortcut so that you don't need to open a terminal each time. To do so, first make a small script using a plain text editor. The contents of the script are:

#! /usr/bin/env bash

gnome-screenshot -a -f ~/Desktop/Screenshots/$(date +%Y%m%d%H%M%S).png

Save the file as a plain text file with an informative name such as my-gnome-screenshot and put the file in ~/bin. If you don't have such a folder, create one.

Then, using your file manager, right-click on the file, choose properties and set the file to be executable by owner. If you're comfortable with the terminal, just run chmod +x ~/bin/my-gnome-screenshot.

Now, use your desktop environment's keyboard shortcut editor/creator to assign a keyboard shortcut to your script.

Then, each time you want to take a screenshot, just press the relevant keyboard shortcut.

Depending on your desktop environment, creating a script may not be needed. In Openbox which is the default window manager of Lubuntu, one can simply edit the rc.xml (or lubuntu-rc.xml) file to contain this keybind (or whatever is suitable and available):

<keybind key="W-4">        # gnome-screenshot of selected ares
  <action name="Execute">
    <command>sh -c 'gnome-screenshot -p -a -f ~/Desktop/Screenshots/$(date +%Y%m%d%H%M%S).png'</command>
  </action>
</keybind>

If you wish to create a .desktop file for launching the script instead of using the terminal or a keyboard shortcut, the procedure is similar to what is described in the answer to Timestamp in Exec= line of .desktop file possible?.

4
  • It's almost good but I would still like to be able to define the input area with the mouse as usual. Like if I want a specific part of the screen. Is it possible to add that functionality to the one-liner?
    – Vesa
    May 29, 2016 at 9:13
  • I tried to do it the easy way and add it through System Settings -> Keyboard -> Shortcuts. It almost works, it does save to desktop but the date syntax might be wrong because every image is saved as $(date. This is what I used: gnome-screenshot -a -f ~/Desktop/Screenshots/$(date +%Y%m%d%H%M%S).png
    – Vesa
    May 30, 2016 at 9:58
  • It worked, thanks. I just removed the ~ like so: sh -c 'gnome-screenshot -a -f /home/user/Desktop/$(date +%Y%m%d%H%M%S).png'
    – Vesa
    May 31, 2016 at 2:36
  • Well done DK Bose. I might be using this tool a lot.
    – Vesa
    May 31, 2016 at 7:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .