Skip to content

Easy screenshots with the keyboard in Linux

There was an article today at Linux.com that reviews various screenshot programs available for Linux. What it doesn’t tell you, is how to take screenshots painlessly in Linux. Let me try and do that. Since I use a Mac, I’m quite used to the Mac OS X way – Command+Shift+3 takes a full screenshots and leaves a PNG file on your desktop, and Command+Shift+4 allows you to select a region for a screenshot.

Duplicating that in Linux is quite simple. First, you need scrot, a command-line program mentioned in the article linked above. Fedora users can get it through yum (yum install scrot). Otherwise you’ll need to download and compile it.

Next, we need to setup the keyboard shortcuts. I’ll describe this for KDE, but I’m sure there’s an equivalent way to do this in GNOME. In KDE (3.5) go to Control Center -> Regional & Accessibility -> Input actions. Create a new action of type “Keyboard Shortcut -> Command/URL (simple)”. I setup Ctrl+Shift+3 to the command scrot ~/Desktop/scr`date +%d%b%y_%H%M%S`.png and Ctrl+Shift+4 to the command scrot -s ~/Desktop/scr`date +%d%b%y_%H%M%S`.png. See the screenshot below (click for larger image).


Screenshots in KDE

Now, pressing Ctrl+Shift+3 puts a full screenshot on your desktop, and pressing Ctrl+Shift+4 allows you to either select a window (single click in a window) or select a region of the screen (click and drag rectangle) and the appropriate capture will be placed on the desktop. The files are dated and timed, so they should be easy to find.

4 Comments

  1. antrix wrote:

    No KDE install handy but KSnapshot probably has some dcop interfaces to do this. Will eliminate the need to install an extra application. But yeah, ‘Input Actions’ are really powerful!

    Wednesday, October 25, 2006 at 12:00 pm | Permalink
  2. Anshul wrote:

    I actually tried to see if KSnapshot could be accessed this way – and I couldn’t find anything. Let me know if you do.

    Sometimes they forget the obvious – the ksnapshot command has a number of options specific to KDE and QT – but no option to simply send the snapshot to a file.

    Wednesday, October 25, 2006 at 1:24 pm | Permalink
  3. Adrian wrote:

    The gnome-screenshot tool is the same. It includes a command line option which allows you to capture a single window and add a drop shadow, but not a simple file output capability which would make a shell script very easy to write.

    I had forgotten about the command-shift-3 screenshots which macs have had forever. I now use linux exclusively, but the mac I bought in 1993 has this feature.

    Thursday, October 26, 2006 at 5:56 pm | Permalink
  4. Arun wrote:

    Have you tried Command+Shift+4+Space on the Mac.
    It takes a screenshot of the active window.

    Saturday, October 28, 2006 at 4:05 pm | Permalink

Post a Comment

Your email is never published nor shared.