Sometimes can be useful to have a small program that you can run from the command line and able to do a screenshot of your desktop or just a portion of it, for this task the perfect software is:
Scrot (SCReenshOT) is a screen capture utility using the imlib2 library to aquire and save images.
scrot has a few really interesting options, detailed below. The basic usage is to specify a [file] as the filename to save the screenshot to and
scrot will take a screenshot of the whole desktop.
The latest release (0.8) has almost 10 years, still this small program can be useful for his ability to be run completely from the command line and so you could use it to concatenate other commands or just because it’s really lightweight and easy to use.
You can install scrot on any Linux distribution. If you’re using an Ubuntu or a derivate like me, or another distro with a package manager, the installation will likely be a matter of running a single command in your terminal. On Mint, you can install scrot with either the Synaptic Package Manager or by simply running the following command:
sudo apt-get install scrot
Scrot follows the main Unix philosophy “Write programs that do one thing and do it well. Write programs to work together. Write programs to handle text streams, because that is a universal interface.”, so it just take screenshots but it does this perfectly and you have also some interesting options that should satisfy most of your needs:
Screenshot of the whole desktop
Just use the command
scrot and add a file name as option:
$ scrot /tmp/desktop.png
This will produce a .png file in your /tmp directory with an image of your whole desktop.
Screenshot of a selected area
If you want to capture a specific window or a rectangular area on the screen, you can use
scrot with the option -s (select) which allows you to interactively draw with your mouse the area to be captured.
$ scrot -s /tmp/myarea.png
Once run the command use the mouse to select one of the corner and press (and keep pressed) the left mouse button to select the area, release the button to save the area.
Add a delay before taking a screenshot
Sometimes you have to open a new windows, or minimize/maximize some windows between you run
scrot and you want the screenshot, for these needs you can use the option -d (delay) that takes a numeric argument that represent the number of seconds to wait before taking the screenshot.
To add some “effects” you can use also the option -c (countdown) that will show on screen a countdown to the screenshot:
$ scrot -d 15 -c /tmp/desktop.png Taking shot in 15.. 14.. 13.. 12.. 11.. 10.. 9.. 8.. 7.. 6.. 5.. 4.. 3.. 2.. 1.. 0.
Making a Thumbnails of the Screen Shot
Another nice feature of
scrot is the possibility of making automatically a thumbnail with the option -t (thumbnail). If you’d like scrot to also create a thumbnail of the screen shot, just specify the -t switch followed by the percentage compared to the original screen shot size that you’d like to make the thumbnail.
The following command creates a thumbnail 50% the size of the original.
$ scrot -t 50% /tmp/desktop.png
The output of this command are 2 files:
ls -alrt /tmp/desktop* -rw-r--r-- 1 linuxaria linuxaria 850568 Apr 14 23:37 /tmp/desktop.png -rw-r--r-- 1 linuxaria linuxaria 226898 Apr 14 23:37 /tmp/desktop-thumb.png file /tmp/desktop* /tmp/desktop.png: PNG image data, 1920 x 1080, 8-bit/color RGB, non-interlaced /tmp/desktop-thumb.png: PNG image data, 960 x 540, 8-bit/color RGB, non-interlaced
So 2 files, one at 1920 x 1080 the resolution of my desktop, and the other at 50% so 960 x 540
Setting the Quality of your screenshot
You can also select the quality of the resulting screen shot image with the -q option followed by a quality level between 1 and 100 (the higher the value, the higher the quality and lower the compression). The default quality level is 75, and the resulting output will of course differ depending on the file format you choose.
Concatenate multiple commands
You can also have another command or program run against the saved screen shot image
scrot creates by using the -e option
$ scrot -ucd4 -e 'eog $f'
This takes a screenshot of the focused window with a 4 second countdown and shows it on EyeOfGnome.
or a more complex example:
scrot -e 'mv $f \$HOME/public_html/shots/; echo "http://\$HOSTNAME/~\$USER/shots/$f" | xsel -i; feh `xsel -o`'
A web server using $HOME/public_html as user directory is required, $HOME/public_html/shots must exist and have appropriate access rights and $HOSTNAME must be known to and accessible from the outside world.
The command uses scrot to create a screen shot, moves it to the screen shot directory, uses xsel to copy the URL to the paste buffer (so that you can paste it with a middle click) and finally uses feh to display a preview of the screen shot.
- An introduction to systemd for CentOS 7
- Linux Games: Sanctum 2
- What goes around comes around: nearly half of DDoS attacked companies are hit twice or more
- Linux Terminal: An lsof Primer
- How to check if you are vulnerable to shellshock
Find me on Google+