By Kurt Qian Jul 6, 2009
Scrot (SCReenshOT) is a Linux command line utility for taking screen shots of your Desktop, inside of a shell / terminal, or of specific windows. The scrot utility is great because it's lightweight, powerful and very flexible. When it comes to screen shot utilities, scrot is definitely a must have.
What is Scrot?
Scrot (SCReenshOT) is a Linux command line utility for taking screen shots of your Desktop, inside of a shell / terminal, or of specific windows. The scrot utility is great because it's lightweight, powerful and very flexible. Scrot is like the Linux "import" command, but scrot uses imlib2 library
. When it comes to screen shot utilities, scrot is definitely a must have.
Download and Install
You can install scrot on any Linux distribution. If you're using Ubuntu 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 Ubuntu, you can install scrot with either the Synaptic Package Manager
or by simply running the following command:
sudo apt-get install scrot
If you have to install from source code, you can get scrot at http://linuxbrit.co.uk/scrot/
Generally speaking, scrot can capture an image of your entire desktop, a specific window on your desktop or your terminal. You can even use scrot to take screen shots of a shell / terminal on systems that don't have a GUI
. Scrot supports multiple image formats (JPG, GIF, PNG etc) which you can specify by simply using the appropriate file extension when using the tool.
Desktop Screen Shot
Let's start out with a simple example by taking a screen shot of the entire Desktop. Run the following command in your terminal (the screen shot will be saved as desktop.png
under the path /
Window Screen Shot
If there is a specific window or rectangular area on the screen you'd like to take a screen shot of, you can use the following command which allows you to interactively draw with your mouse the area to be captured.
Delayed Capture / Countdown
Scrot has the ability to use a timer to delay the actual screen capture. This way, if you're trying to take a screen shot as you work on something you'll have time to prepare the screen for the screen shot. You can use the -d
switch followed by the number of seconds to delay the capture. The following example waits 5 seconds.
You can also use a "countdown" with the -c
switch. The following command will delay the screen capture for 5 seconds and count down in your terminal from 5 to 1.
scrot -cd 5 /countdown.png
Screen Shot Thumbnails
Another neat feature scrot has is the -t
switch (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. For example, 50% would create an image half the size of the original. You can also specify a geometry such as 80x30 or 30x80.
The following example creates a thumbnail 25% the size of the original.
Adjusting the Quality
You can also optimize the quality of the resulting screen shot image with the -q
switch 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.
The following command will create an image at 70% the quality of the original high quality screen capture that scrot takes.
You can also have another command or program run against the saved screen shot image scrot creates by using the -e
switch. For example, the following command will move the saved image to another folder.
scrot operation.png -e 'mv $f /home/kurt/Desktop/'
If you're wondering where the $f
came from, see the next section.
parameters can both accept two types of format specifiers. Characters starting with a '%
' are interpreted by strftime
(2), which may be used to reference the current date and time. The following example will use the Scrot also supports the following internal specifiers, which begin with a $ dollar symbol.
- $f image path/filename (ignored when used in the filename)
- $n image name (ignored when used in the filename)
- $s image size (bytes) (ignored when used in the filename)
- $p image pixel size
- $w image width
- $h image height
- $t image format
- $$ prints a literal '$'
This last example uses the date and screen dimensions as the file name.