Scrot: A Command Line Tool to Take Desktop/Server Screenshots Automatically in Linux

[‘

n

Scrot (SCReenshOT) is an open source, powerful and flexible, command line utility for taking screen shots of your Desktop, Terminal or a Specific Window manually or automatically by Cron job. Scrot is similar to Linux ‘import‘ command, but uses ‘imlib2‘ library to capture and save images. It supports multiple image formats (JPG, PNG, GIF, etc), which you can specify while taking screen shots by using the tool.

n

Install Scrot Screenshot Tool in Linux
Scrot Screenshot Tool

n

Features of Scrot

n

    n

  1. With scrot we can take screen shots easily without any additional work.
  2. n

  3. We can also optimize the quality of the screen shots image (with the -q switch, followed by a quality level between 1 and 100. The default quality level is 75.
  4. n

  5. It is very easy to installation and use.
  6. n

  7. We can capture a specific window or a rectangular area on the screen with the help of switch.
  8. n

  9. Can get all screen shots in a particular directory and also can store all screen shots in a remote PC or network server.
  10. n

  11. Can monitor all Desktop PC in admin absent and prevent to unwanted activities.
  12. n

n

Installing Scrot in Linux

n

We can install ‘Scrot‘ on any Linux distribution. If you’re using RedHat or Debian based distribution, you can use a package manager tool like yum or apt-get to install it as shown below.

n

# yum install scrotttt[On RedHat based Systems]

n

$ sudo apt-get install scrottt[On Debian based Systems]

n

If you wish to install it from source code, then use the following commands.

n

$ wget http://linuxbrit.co.uk/downloads/scrot-0.8.tar.gzrn$ tar -xvf scrot-0.8.tar.gzrn$ cd /scrot-0.8rn$ ./configurern$ makern$ su -c "make install"

n

Note: RedHat users, need to specify prefix location with configure command.

n

$ ./configure --prefix=/usr

n

How to Use Scrot to take Screen shots

n

As I said above, scrot can capture an entire desktop, a terminal or a specific window. With the help of scrot you can also take screen shots of a shell/terminal of a system that doesn’t have a GUI support.

n

Take Full Desktop Screen Shot

n

Let’s take a entire screen shot of the Desktop, using the following command in your terminal.

n

$ scrot /home/tecmint/Desktop.jpg

n

Desktop Screen Shot
Desktop Screen Shot

n

Take Specific Window Screen Shot

n

If you would like to capture a specific area on the screen, you can use the following command with ‘-s’ switch that allows you to interactively select the area with your mouse that you wish to take screen shot.

n

scrot -s /home/tecmint/Window.jpg

n

Take Selected Window Screen shot
Take Selected Window Screen shot

n

Adjusting the Image Quality

n

With the help of ‘-q‘ switch, you can specify the quality level of the image between 1 and 100. The default image level is set to 75, and the image output will be different depending upon the file format you specify.

n

The following command will capture an image at 90% the quality of the original high quality screen.

n

$ scrot -q 90 /home/tecmint/Quality.jpg

n

Take Quality Screen shot
Take Quality Screen shot

n

Take Screen Shots Automatically

n

Now if you would like to get automatically screen shots, than you need to create a simple shell script. Create a file ‘screen.sh‘ with ‘touch‘ command and add the following content to it.

n

#!/bin/shrnDISPLAY=:0 scrot 'tecmint-%Y-%m-%d-%H_%M.jpg' -q 20 && mv /home/tecmint/*.jpg /media/tecmint

n

Now grant ‘777‘ permission and set an Cron job.

n

$ chmod 777 screen.sh

n

Open a ‘crontab‘ file and add the following entry. You can define custom interval time.

n

$ crontab -e

n

*/1 * * * * sh /home/tecmint/screen.sh

n

The above Cron entry will run every ‘1‘ minute and take screen shots and store them under ‘/media/tecmint‘ directory with filename as date and time. After running script for 1 minute, this is what I found in my ‘tecmint’ directory.

n

Automatic Screen shots
Automatic Screen shots

n

Reference Links

n

http://linuxbrit.co.uk/software/

n

‘]