Web Projects Consulting

The Quickest Self-Brewed Screen Grabber for Linux

Sometimes you need to make a series of screenshots very quickly, and you have no time to think about output file names and the rest of the things. However, in Linux you can do this only typing one letter and clicking a mouse button.

First we check if the software we need exists:

import --version

If you see this:

Version: ImageMagick 6.6.4-1 2010-12-17 Q16 //www.imagemagick.org
Copyright: Copyright (C) 1999-2010 ImageMagick Studio LLC
Features: OpenMP 

it means no other steps necessary, otherise install ImageMagick with:

sudo yum -y install ImageMagick

After the software in installed, create the bash script you will use:

mkdir -p ~/bin
touch ~/bin/g
chmod a+x ~/bin/g
gedit ~/bin/g

Copy, paste and save:

#!/bin/bash
DIR=pwd
NUM=ls -1 | wc -l
FILL=printf "%04d" $NUM
import "$DIR/$FILL.png"

Add “bin” directory to your path so that it works from any directory (if not done before):

echo 'PATH="$PATH:$HOME/bin"' >> ~/.bash_profile

Now you have log out and log in back so that the changes take place.

Create an empty directory for your screenshots:

mkdir test
cd test

Using the whole thing is just typing in console (I love yakuake, it retracts with F12 and the desktop is all yours) like:

g

hit ENTER (watch the cursor turning into a cross) and click any window.

The script will create a file which name will be [NUMBER OF FILES+DIRS IN A DIRECTORY + 1].png, namely “0001.png” for an empty folder.

If you repeat the operation, the next file name will be “0002.png” and so on.

In 2 minutes you will learn how to make a screenshot within a part of a second without thinking of file names and the other stuff.

Enjoy!

(You can also design a key binding for that but this is a completely different story.)

Leave a 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.