How to Take a Screenshot on Raspberry Pi Using scrot

For many of my tutorials, I use a Raspberry Pi computer when analyzing data in Python or writing scripts under the Arduino platform. In order to convey information, I often take screenshots to demonstrate more complex or convoluted steps involved in a project. In Linux, there is a tool called 'scrot' which takes screenshots very easily via the command window. Raspberry Pi is fully compatible with 'scrot' so I will outline its potential uses and capabilities here.


Installing 'scrot' and Taking Your First Screenshot

pi@raspberrypi:~$ sudo apt-get install scrot

The simplest method for using 'scrot' is to simply input 'scrot' into the command window. This will save a screenshot of the entire Raspberry Pi window under the /home/pi directory under the format 'year-month-day-time_size_scrot.png'

pi@raspberrypi:~$ scrot

Screenshot of the entire screen

Under the folder '/home/pi' you should see a screenshot with the current year as the first part of the '.png' file.


Saving Screenshot Directly to A Folder

If you want to save the screenshot directly to a specific folder instead of having to copy and paste or move the screenshot, you can follow 'scrot' with the folder and filename desired for the screenshot, without having to ever move the file. The folder needs to exist already, so be sure that the directory exists before trying to 'scrot' to it.

pi@raspberrypi:~$ scrot /home/pi/screenshots/test.png

Screenshot Delays and Window Specification

The user may not want to take a screenshot of the entire screen, so 'scrot' also allows control of the screenshot window. This can be done using the following method:

pi@raspberrypi:~$ scrot -u /home/pi/screenshots/test.png

Another method for getting a full screenshot of the current window is to include the border by adding a 'b' next to the 'u':

pi@raspberrypi:~$ scrot -bu /home/pi/screenshots/test.png

Another adjustment the user may want to do is introduce a delay before the screenshot is taken so they can prepare the screen after initiating the 'scrot' command. This can be done with the following introduction of the '--delay s' command:

Screenshot including the border of the current window

pi@raspberrypi:~$ scrot --delay 5 -bu /home/pi/screenshots/test.png

It is easy to see how the user has quite a bit of control with the use of 'scrot' and the parameters available for alterations. The user can specify a delay, they can specify the window, and they can specify the location for the screenshot to be saved. It is an incredibly useful tool for instructors, teachers, and authors.