Scrot is a simple tool for taking screenshots. It is a flexible and minimalistic, fast and simple command line utility. Scrot works on all window managers, include tiling-based dwm, i3wm, bspwm.
So if you want to install some simple utility for taking screenshots and bind it with likable shortcut scrot is a good choice. It is also chosen by Arch Linux users due to its simplicity and compatibility.
Here is what the man page says:
BUGS:scrot manual page
Scrot + FFmpeg. Using additional tools for better screenshot compression
Scrot supports PNG, JPEG formats. Also you can use this article (JPEG and PNG compression quality with ffmpeg) to compress with your own settings:
scrot '/tmp/lossless.png' -e 'ffmpeg -hide_banner -i $f -compression_level 100 ~/Screenshots/%Y-%m-%d-%H:%M:%S.jpg && rm $f'
The command above takes a screenshot and saves it in PNG (lossless) format. Then ffmpeg runs and compresses the screenshot in JPEG format with our own settings. Then PNG screenshot will removed. Finally we have JPEG screenshot with our own parameters of compression.
But scrot provides its own -q parameter to control quality level. We can use it instead. I tried it, but I didn’t like it, ffmpeg gives the best results. My PNG image has been compressed in 6 times to JPEG format (1.2 M -> 200 kB). Using –q 100 (maximum quality) parameter gave bad results (800 kB with same quality).
scrot and ffmpeg use different libraries for compression therefore compression results are different. We must don’t forget that ffmpeg regularly updates its libraries, therefore, it is preferable to use ffmpeg for media compression.
The possibilities are much more because we have access to all ffmpeg video filters. Take a look at this example:
scrot '/tmp/lossless.png' -e 'ffmpeg -hide_banner -i $f -vf scale=iw/2:ih/2 -compression_level 100 /Screenshots/%Y-%m-%d-%H:%M:%S.jpg && rm $f'
This command will reduce the size (Width x Height) of the screenshot in half. So, if our image is really big, we can regulate the size of it.
To install scrot on Debian-based distributions make:
sudo apt install scrot
Most useful scrot options
Use -u option to use currently focused window:
We can add a delay before focusing on the window. Use -d ‘time in seconds’:
scrot -u -d 5
Add -c option to show coundown in the terminal:
scrot -u -d 5 -c
We can select screenshot area using -s option. Use mouse pointer and hold left mouse button to select area:
Add -q ‘image quality in 0-100 range’ to use native image compression. It is 75 by default
scrot -q 90
By -b option we can make scrot to grab border of a window too:
scrot -u -b
But it is border of WM! Not terminal! So, on my dwm there is no window borders that dwm apply, so i use borders of urxvt terminal therefore it has no effect on me!