April 25, 2011, 3:23 a.m.
posted by ccall
Take a Screenshot
If you spend any time changing the look of your desktop with fancy themes and icons, what fun is it if you don't post your new cool desktop for everyone to see? The final proof of any successful desktop tweaking is a screenshot you can show off to your friends. You can use a number of methods to take screenshots, and this hack introduces you to some of the most common ones.
From the Command Line
One of the simplest and most universal ways to take a screenshot is with the import command from the ImageMagick suite of utilities. This is a very common tool, and chances are that ImageMagick is already installed by your distribution; if not, packages should be readily available. import has two major screenshot modes. To take a picture of the entire screen, type:
$ import -window root screenshot.png
The -window root argument tells import to take a picture of the entire screen. If you type:
$ import screenshot.png
Your cursor turns into crosshairs, allowing you to drag across the section of screen you want to copy. Once you release the mouse button, the part of the screen that is selected becomes the part import will put into your image. import supports all common image formats used for screenshots, including JPEG, PNG, and BMP (useful for lossless screenshots). All you have to do is name your output file with the file extension you wantimport will figure out the rest.
If you want to set a time delay so you can arrange your windows or possibly hide the terminal containing the import command, just preface your import command with sleep. To allow five seconds before a screenshot is taken, type:
$ sleep 5; import -window root screenshot.png
$ import -window root `date +%Y-%m-%d`.png
From Within GNOME
GNOME uses its own screenshot program called gnome-panel-screenshot. This program can be accessed a number of ways, but probably the easiest is to press the Print Screen key on your keyboard. This immediately takes a screenshot of the entire screen and displays a dialog you can use to name and save the screenshot file. To take a picture of the current window, just press AltPrint Screen instead. This program is also accessible in the panel menu. Click Actions Take Screenshot. You can even access this program directly from the command line with:
$ gnome-panel-screenshot --delay 5
From Within KDE
If you use the KDE desktop, ksnapshot is the KDE alternative to gnome-panel-screenshot and can usually be found within the K Menu Graphics menu. The GUI allows you to choose a delay, take a screenshot, and choose whether to take the screenshot of the entire desktop or just the current window. You can, of course, also start ksnapshot just by typing ksnapshot in a terminal window or in the Run Command window, which you can access by pressing Alt-F2.