Replacing gnome-screenshot with ksnapshot

Update 2010-12-06: Ray points out that you can do this with gconf-editor, which is a much better solution.

It’s a handy feature of Gnome that pressing “PrntScrn” or “Alt+PrntScrn” will take a screen capture of the desktop or current window, respectively. However, in typical Gnome fashion, you can’t do anything more advanced. You can’t capture a region, or a window area. You can’t delay the capture. You can’t save the captures with iterating, numbered filenames. However, the equivalent KDE tool can do all of those things, and you can make Gnome use it.

When you press the PrntScrn key, Gnome calls gnome-screenshot. When you press Alt+PrntScrn, it calls gnome-screenshot --window. Again, typical Gnome design means you cannot configure what command is called. But you can make your own gnome-screenshot script which calls ksnapshot.

Create a script in /usr/local/bin or $HOME/bin (if you have that in your path), and edit it.

sudo touch /usr/local/bin/gnome-screenshot
sudo chmod 755 /usr/local/bin/gnome-screenshot
sudo vi /usr/local/bin/gnome-screenshot

Now paste in the following:

#!/bin/sh
if [ "$1" = "--window" ] ; then
   ksnapshot -c
else
   ksnapshot
fi

Save and quit, and you’re done! Pressing PrntScrn now opens ksnapshot.

Tags: ,

  1. The Open Sourcerer’s avatar

    Hi Tyler,

    I think you just need to use gnome-screenshot –interactive to get the dialogue box that enables you to choose your settings. You can also use -a (Grab area), -d X (Delay Xs) for example.

    $ gnome-screenshot –help
    Usage:
    gnome-screenshot [OPTION…] Take a picture of the screen

    Help Options:
    -h, –help Show help options
    –help-all Show all help options
    –help-gtk Show GTK+ Options

    Application Options:
    -w, –window Grab a window instead of the entire screen
    -a, –area Grab an area of the screen instead of the entire screen
    -b, –include-border Include the window border with the screenshot
    -B, –remove-border Remove the window border from the screenshot
    -d, –delay=seconds Take screenshot after specified delay [in seconds]
    -e, –border-effect=effect Effect to add to the border (shadow, border or none)
    -i, –interactive Interactively set options
    –display=DISPLAY X display to use

    Reply

    1. Tyler Wagner’s avatar

      The interactive switch is helpful, thanks. However, it still lacks iterative numbering of files, and it doesn’t keep taking shots after the first.

      Reply

    2. Ray Lee’s avatar

      No need to go through all that. Gnome most certainly *does* allow you to change this. Run gconf-editor, navigate through to apps >> metacity >> keybinding_commands and change the gnome-screenshot bindings to ksnapshot.

      gconf-editor is your friend. Gnome has most of these things configurable, but has consistently stated that it won’t be in the *default* UIs for people. They’d be happy for someone to write a ‘power user’ tool, but there’s little call for it.

      Reply

      1. Tyler Wagner’s avatar

        Doh! I missed that in gconf. I assumed Metacity key bindings had no effect in Compiz. Thanks!

        Reply

Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.