I already know of the Prt Scrn key method of taking a screenshot in Ubuntu. Which when press takes a screenshot and prompts you to save it.
for example:
Is there anyway to have Ubuntu save the screenshot automatically without prompting me to save?
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.
Sign up to join this communityI already know of the Prt Scrn key method of taking a screenshot in Ubuntu. Which when press takes a screenshot and prompts you to save it.
for example:
Is there anyway to have Ubuntu save the screenshot automatically without prompting me to save?
You can do that by installing scrot command-line screenshot tool and setting CompizConfig Settings Manager to use scrot when Prt Scr key is pressed:
Install scrot using the following command in terminal or using software center:
sudo apt install scrot
Open gedit as root by pressing Alt + F2 and running gksu gedit
. In gedit paste the following code:
#!/bin/sh
mkdir ~/Pictures/Screenshots
scrot 'Screenshot_%Y-%m-%d_%H-%M-%S.jpg' -e 'mv $f ~/Pictures/Screenshots/'
You can change the way it saves the screenshot by changing the above command.
Save the file with the desired filename in /usr/bin/
and close gedit. Let us assume you saved it as scrot-sreenshot
for the next steps.
In terminal run the following command:
sudo chmod 755 /usr/bin/scrot-screenshot
Open CompizConfig Settings Manager. If you don't have it installed, please install it first.
Click on Commands and enable that.
In a Command-line field in the Commands tab, enter scrot-screenshot
(let us assume you selected Command line 0).
In the Key Bindings tab, in Run Command 0, enable it by clicking on the button which says Disabled -if it was not previously configured- and ticking the checkbox saying Enabled.
Click on Grab Key Combination and press Prt Scr. It will show you a warning saying that the key is already used by Take a Screenshot and let's you to disable it. Disable Take a screnshot and everything should work as you want.
You can do it in a simple way:
Open "CompizConfig Settings Manager". If you don't have it installed, you'll need to install it.
Click on Commands and enable it.
Choose one empty Command line field, e.g. 0, and input: gnome-screenshot -f $HOME/Pictures/"Screenshot from $(date +%Y-%m-%d%t%H-%M-%S)".png
In the Key Bindings tab, in Run Command 0, enable it by clicking on the button which says Disabled -if it was not previously configured- and ticking the checkbox saying Enabled.
Click on Grab Key Combination and press Prt Scr
. It may show you a warning saying that the key is already used by Take a Screenshot and allows you to disable it. Disable Take a screnshot and everything should work as you want. If the warning is not shown, open System Settings -> Keyboard -> Shortcuts -> Screenshots and disable or change the shortcut "Take a screenshot".
Basically, no need to install other screenshot software, or deal with scripts. Gnome-screenshot knows how to autosave if you provide the save path. Of course, feel free to choose a different save path or date/time format, in the example I used a similar one to the default. You can also change other options as in grabbing just the current window, etc; you may see the available options in gnome-screenshot --help
. This solution works with older versions of Ubuntu as well, e.g. 16.04.