How to take screenshots with Scrot

How to take screenshots with Scrot


Screenshots. Where would the internet be without them? They are ubiquitous and when you are researching that latest piece of cool software or the latest ISO of your favourite GNU/Linux distro they are an opportunity to preview the eye candy. There are many ways to make those screenshots and most KDE and Gnome users will be familiar with the GUI tools bundled with them: Ksnapshot for KDE and Take Screenshot for Gnome. They are good at what they do. However, sometimes you just need to take screenshots quick and dirty without the overheads (especially if you are using a lightweight windows manager on a relatively low-spec machine). If that's your case, you can use “Scrot”.

Welcome to Scrot

Scrot (SCReenshOT) will probably not come pre-installed with your distro; so, as ever, it is a case of a quick visit to the software repositories. If that turns up a blank you should be able to download a source tarball or a pre-compiled binary at the official site. If not you can always get it at Klik which should install it for you across a wide range of distros. Just follow the instructions on the website to enable the Konqueror and Firefox browsers to use it.

This is not the place to launch into a detailed comparison of available screenshot tools, graphical or command line. Suffice it to say, by the end of this article, I hope I will have demonstrated the power and utility of Scrot which, despite being a command-line tool, offers the user an excellent screenshot tool with power options to suit most requirements. If you want to see the commands Scrot supports just type man scrot in a terminal.

Ways of running Scrot

Scrot is a command-line tool (written in C and using the imlib2 library); so obviously you will be running it in a console within your X windows session.

I find that in order to clear the way for the screenshot quickly and to avoid switching between the mouse and the keyboard, it is useful to have Yakuake installed. It is a Quake-style terminal emulator. You can either use your package manager to install it (if available) or get Yakuake here. Once installed and run, the terminal screen can be pulled down and retracted very quickly by toggling the F12 key. This is very useful speed tweak after you have issued a Scrot command.

However, there is an even better way to launch a Scrot command: just press Alt+F2 and type in scrot, hit run and you're done.

If you want to take it one step further and avoid the hassle of even opening the run dialogue, then right-click on an empty space on the taskbar and select Add Applet to Panel and from the GUI scroll down to Run Command, click on it and add it to the panel. This will add the ability to type commands directly into the Gnome panel. So, you can type a Scrot command directly into the panel without ever needing to open a console in an X-windows session or call up Alt+F2 again. The added bonus of taking a few seconds out to set this up is that it will persist across reboots and always be there to launch any programme without resort to the Start menu or Alt+F2.

Inevitably you will want to take more than simple screenshots, especially where it involves demonstrating menus, submenus and tabs. As with graphical tools like Ksnapshot you will need to incorporate a delay whilst you set up the screenshot. If it involves a lot of navigation through a thicket of menus/tabs then it it a good idea to do a dry run and roughly time how long it takes to set up that screenshot and then add on an extra five seconds to allow for sloppy mouse actions. Once you have done this you are ready to craft a Scrot command.

Don't delay—or rather, do

Having done everything in two preceding paragraphs, go ahead and set up a command. Here is one which will take a screenshot in the JPEG format after a delay (to allow you time to set it all up) of, say, 5 seconds:

scrot -d 5 desktop.jpeg

We have liftoff!

NASA aren't the only ones who can launch with a countdown. If you like all the bells and whistles, you can run a neat little countdown facility by adding a simple parameter to that command. Just type:

scrot -d 15 -c desktop.png

and you can experience the dubious pleasure of watching Scrot flaunting it's numeracy skills.

The length of the delay you set will depend on the simplicity or complexity of the screenshot you are setting up and you will of course give it a contextually appropriate name. Scrot is not too strict as regards syntax. The last command could also have been typed as:

scrot desktop.png -d 15 -c

and it works equally well. If you wish to specify a window or part of a screen (use your mouse to draw out a selected area) then just append -s thus:

 
scrot desktop.png -s

and then use your cursor to draw out the area for your screenshot. A number of useful points here: by default, Scrot automatically saves screenshots to the current directory you are in (usually the home directory) so if you wish to save to a different one, cd to it first before executing a command. Like ImageMagick, another useful command-line tool for taking screenshots, Scrot supports many formats including, of course, the ubiquitous PNG and JPEG formats.

Scrot's other tricks

Scrot can do all of the above but it has a few more tricks up it's sleeve: if you want to create thumbnails for a web gallery or to save space by way of compression, you can always do so manipulating the screenshot later using a program like Gimp. Scrot can incorporate that in one line by simply adding the -t option followed by the percentage by which you want to compress it. If you want to include the WM border too, append -b. You can set the quality (size and compression) with -q followed by a number between one and one hundred (seventy five is the default).

OK, say cheese everyone...

We all like to find clever and cool ways to do things, and if you have acquired any reasonable command-line skills then you won't need to be a genius to think of ways to combine that knowledge with Scrot's power. Once a screenshot has been taken, you might want to do some editing—to change format, compress, crop, resize etc. Normally, you will right click on the saved image and select the graphical tool of choice to do the job, or just open the graphics package separately and navigate to the relevant directory; however a little command-line magic can do that for you too. When you want to run multiple commands you can join them together by using the double ampersand. This means that if the previous command is true it will execute the following one. In this case you can append the name of the graphical package of choice for editing the screenshot Scrot has just taken.

So, let's put all those options together in one big line and run it:

scrot -d 5 -q 95 -t 30 screenshot.jpeg -b -s && gwenview screenshot.jpeg

Done! Yes, it's a bit of a mouthful but once you've memorised it Scrot is a very powerful and useful piece of software and doubtless readers can think of many commands that can be used in conjunction with Scrot to extend its utility. The only features it seems to lack are the ability to convert image formats and take multiple screenshots. For that you will have to use ImageMagick— which, fortunately, comes pre-installed with most GNU/Linux distros.

Snap it the ImageMagick way

Although this article has been about Scrot I can't resist finishing off with a very brief howto with ImageMagick for taking multiple screenshot in one command-line pass. This is one feature that would make Scrot complete and it's called snap. Append this parameter to the basic import command and you can take multiple screenshots of the number you specify:

import -delay 20 -snaps 4 snapit.jpeg

Prepare the screens you want to capture, mimimize them all, type that command and then use Alt+Tab to toggle through them one at time, clicking on each one. (You can type into the Run command box in the Panel as per Scrot.) Go to the directory in which you saved them and you will see the screenshots. They will all have the same name (in this instance "snapit") and they will be numbered from 0 through to 3—four in total. Neat. Obviously, you can specify the number of snaps and of course, like Scrot, you can specify the format, amongst other things.

A disclaimer

For all of you who have the welfare of open-source software close to your hearts I wish to assure you that no GUI graphics packages were harmed in the making of this article.

Category: 

Comments

clievers's picture
Submitted by clievers on

Thanks for the article, it is well written and easy to understand and follow. This is very good to know, as we definitely all do screenshots at one time or another. :-)

------
let's all play nice!

Author information

Gary Richmond's picture

Biography

A retired but passionate user of free and open source for nearly ten years, novice Python programmer, Ubuntu user, musical wanabee when "playing" piano and guitar. When not torturing musical instruments, rumoured to be translating Vogon poetry into Swahili.

Most forwarded

Interview with Dave Mohyla, of DTIDATA

Dave Mohyla is the president and founder of dtidata.com, a hard drive recovery facility based in Tampa, Florida.

TM: Where are you based? What does your company do?
DTI Data recovery is based in South Pasadena, Florida which is a suburb of Tampa. We have been here for over 10 years. We operate a bio-metrically secured class 100 clean room where we perform hard drive recovery on all types of hard disks, from laptop hard drives to multi drive RAID systems.

Anybody up to writing good directory software?

Since the very beginning, directories (of any kind) have had a very central role in the internet. (I have recently grown fond of Free Web Directory. Even Slashdot can be considered a directory: a collection of great news and invaluable user-generated comments. As far as software is concerned, doing a quick search on Google about software directories will return the free (as in freedom) software directories like Savannah, SourceForge, Freshmeat and so on, followed by shareware and freeware sites such as FileBuzz, PCWin Download Center and All Freeware (great if you're looking for shareware and freeware, but definitely less comprehensive than their free-as-in-freedom counterparts).

Interview with Mark Shuttleworth

Mark Shuttleworth is the founder of Thawte, the first Certification Authority to sell public SSL certificates. After selling Thawte to Verisign, Mark moved on to training as an astronaut in Russia and visiting space. Once he got back he founded Ubuntu, the leading GNU/Linux distribution. He agreed on releasing a quick interview to Free Software Magazine.

Is better education the key to finding better software?

I read David Jonathon's article Anybody Up To Writing Good Directory Software? the other day, which got me thinking about software directories in general. As David mentioned, many of the software directories one finds when doing a quick google search are free as in beer, not as in freedom. But what interests me is the software directories that already exist, providing a combination of both free as in beer software, and open source software. Sites such as Freeware Downloads and Shareware Download don't advertise themselves as providing free as in liberty software, but each of them have a good selection of open source software available... if you know where to look.

Most emailed

Free Open Document label templates

If you’ve ever spent hours at work doing mailings, cursed your printer for printing outside the lines on your labels, or moaned “There has got to be a better way to do this,” here’s the solution you’ve been looking for. Working smarter, not harder! Worldlabel.com, a manufacture of labels offers Open Office / Libre Office labels templates for downloading in ODF format which will save you time, effort, and (if you want) make really cool-looking labels

Creating a user-centric site in Drupal

A little while ago, while talking in the #drupal mailing list, I showed my latest creation to one of the core developers there. His reaction was "Wow, I am always surprised what people use Drupal for". His surprise is somehow justified: I did create a site for a bunch of entertainers in Perth, a company set to use Drupal to take over the world with Entertainers.Biz.

Update: since writing this article, I have updated the system so that the whole booking process happens online. I will update the article accordingly!

So, why, why do people and companies develop free software?

More and more people are discovering free software. Many people only do so after weeks, or even months, of using it. I wonder, for example, how many Firefox users actually know how free Firefox really is—many of them realise that you can get it for free, but find it hard to believe that anybody can modify it and even redistribute it legally.

When the discovery is made, the first instinct is to ask: why do they do it? Programming is hard work. Even though most (if not all) programmers are driven by their higher-than-normal IQs and their amazing passion for solving problems, it’s still hard to understand why so many of them would donate so much of their time to creating something that they can’t really show off to anybody but their colleagues or geek friends.

Sure, anybody can buy laptops, and just program. No need to get a full-on lab or spend thousands of dollars in equipment. But... is that the full story?

Fun articles

Santa Claus - the most successful open source project

It dawned on me the other day, as I was shopping for the dozens of gifts it seems I have to buy every December, that Santa Claus is the most successful open source project in history. (Bridget @ Illiterarty would agree with that). Santa Claus is essentially a marketing development that is embodied by everyone who stuffs a sock, gives a gift, hosts a dinner or wishes Merry Christmas over the holiday season.

Most emailed

Editorial

When I first started thinking about Free Software Magazine, I was feeling enthusiastic about the dream. I had Dave, Gianluca, and Alan willing to help me, I had established members of the free software community willing to help me out, I had writers volunteering their time and energy for free, and I had a generous offer from OpenHosting for servers, all before I'd proved myself. There was a sense of excitement in the air, and I thought maybe, just maybe, I could make this work.

Free Software Magazine uses Apollo project management software and CRM for its everyday activities!