X-Window: Screenshots

How to take a screen capture when no screenshot tool (Ksnapshot, ...) is installed on your system?

The ImageMagick* package (binary available for most distributions **) contains a dozen commands dedicated to image manipulation.

The one that interests us here is the import command.

import can be called in 2 ways:

$ import filet

$ import -window WinId filet

I invite you to consult the manual (man 1 import) to learn about the other options of this command.

The first call means that you want to capture and store a screenshot in the filet

Where t defines the format of image compression: png, gif, jpg, etc..

Once the command issued, the pointer turns into a cross. We then have two possibilities:

Define an area to capture with a click and drag

Define a window to capture by clicking on the border.

The second call, allows you to specify the window you want to capture through its name or ID.

Where the "root" parameter defines the Desktop.

Knowing this, it is possible to generate a small script to facilitate the use of the import command:

#!/bin/sh #{{{ Vérification de l'existence du binaire import import="/usr/bin/import" if [ ! -x ${import} ]; then echo "${import} not found!" exit 1 fi; #}}} #{{{ Création du dossier "captures" si besoin mkdir -p ~/captures #}}} #{{{ Génération du nom de la capture name=$(date +"%Y.%m.%d-%H.%M.%S") #}}} #{{{ Traitement (basique) de l'argument if [ $# -eq 1 ]; then option=" -window $1" fi; #}}} #{{{ Capture $import $option ~/captures/$name.png #}}}

The purpose of this script:

Verify the presence of the binary.

Creating a folder to store your screenshots in the home directory of the user.

Capture the: entire screen if the "root" option is given, the desired window if its name or Id is passed as a parameter, a particular area with the mouse if no argument,

Save the screenshot in the "png" format as: yearonth.day-hourinutes.seconds.png

All that remains is to configure the following keyboard shortcuts (KHotKeys under KDE)

Hunter Jones

Hunter Jones

Next Post

Leave a Reply

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