2021-07-12
Import Screenshot Utility

When I see recomendations on screenshot applications for Linux it’s usually either scrot or maim. I’m sure there is nothing wrong with them and I have never had any issues with them. A while ago I realized that ImageMagick comes with the import command which has the ability to take screenshots of your screen aswell. Since ImageMagick is installed on all of my machines I see no reason to install an additional application for this.

Taking a screenshot

The command for take a simple screenshot is

import -window root screenshot.png

There is a lot of options you can use if you look at ImageMagicks website or the man page.

How I use it

I have a script that I have a keybinding to that opens a rofi menu with different options.

#!/bin/bash

# options to be displayed
option0="screen"
option1="area"
option2="window"

# options to be displyed
options="$option0\n$option1\n$option2\n$option3\n$option4"

selected="$(echo -e "$options" | rofi -lines 1 -dmenu -p "scrot")"
case $selected in
    "$option0")
		import -window root /hdd/pix/prtsc/"$(date +%Y-%m-%d-%T.png)" && notify-send 'Screenshot' 'Done';;
    "$option1")
		import /hdd/pix/prtsc/"$(date +%Y-%m-%d-%T.png)" && notify-send 'Screenshot' 'Done';;
    "$option2")
		import -window id /hdd/pix/prtsc/"$(date +%Y-%m-%d-%T.png)" && notify-send 'Screenshot' 'Done';;
esac

The first one just takes a screenshot of my whole screen in .png format and set the date and time as filename. After that it sends me a notification that a screenshot is captured

import -window root /hdd/pix/prtsc/$(date +%Y-%m-%d-%T.png) && notify-send 'Screenshot' 'Done';;

In the second option it is almost the same, but without the -window root part. This makes it possible for us to choose which part of the screen we want to capture

import /hdd/pix/prtsc/$(date +%Y-%m-%d-%T.png) && notify-send 'Screenshot' 'Done';;

And the last one is with -window id. With this option we can chose a specific window to capture.

import -window id /hdd/pix/prtsc/$(date +%Y-%m-%d-%T.png) && notify-send 'Screenshot' 'Done';;
#screenshot #imagemagick #import