Furor Teutonicus blog | over | volg | teuto | lyme | archief | doneer | todo
✍️ Evert Mouw
⏱️ 4 min

Screenshot tools for Linux

(This article is meant for [intermediate] and [advanced] Linux users.)

To quickly make screenshots, I consider these popular screenshooter tools:

Because I use XFCE with Arch Linux, I prefer lightweight, fast tools, without loads of dependencies. I also like to autosave screenshots without bothering with questions and user dialog screens. In this blogpost, I will compare a few main features and test the speed of these two utilities. Note that there are many more screenshoters. The screen capture program maim is intended to improve on scrot. While scrot is old, it is fast and gets the job done. Also there is a resurrecting project, which Arch uses. For XFCE users, xfce4-screenshooter is part of xfce4-goodies.

The often recommended shutter tool is less ideal for XFCE as it depends on gnome-vfs in the AUR. The predecessor of shutter was called gscrot and was a perl-based frontend for scrot. It seemsshutter still is such a frontend, and has a lot of perl dependencies. I wanted to try it from AUR but got a build error in thelibwnck+ dependency, so I gave up because it seems shutter does not satisfy my need for a tool with minimal depedencies for XFCE.

Both tools can grab the whole screen, the active screen (in focus), a custom part of the screen, and save the file. Only xfce4-screenshooter can also copy the screenshot to the clipboard; scrot has no option for that. For scrot, that can be solved by using the --exec option combined with the xclip tool. An advantage of scrot is that it can use modifyers for the output filename; so you can use the date and time and other variables in the filename. An advantage ofxfce4-screenshooter is the nice dialog it can show if no options are given on the command line.


Make a screenshot of the whole full screen.

xfce4-screenshooter --fullscreen
scrot --multidisp

Make a screenshot of the active windows in focus.

xfce4-screenshooter --window
scrot --focused --border

Note: The --border option for scrot is optional; it includes the border drawn by the Windows Manager.

Select and store a custom region (rectangle).

xfce4-screenshooter --region
scrot --select

Combined versions: for the active window; copy to clipboard, save to file.

xfce4-screenshooter --window --clipboard --save OUTPUT.png
scrot --focused --border --exec 'xclip -selection clipboard -target image/png -in $f' OUTPUT.png

Speed comparison

The last example above, the combined versions, were tested using time. The xfce4-screenshooter took 0.39 seconds on the 2nd run; the scrot version took 0.10 seconds on the second run. (I tested it for the second run to include caching effects. The first match was also won byscrot.) Clearly scrot is the winner for quick, no-dialog scenarios.

My preferred command

Let’s copy the screenshot itself to the clipboard, and the filename to the “primary” buffer”. To learn more about”primary” and “clipboard”, see clipboards-spec and this question. Also scrot’s ability to include variables in the output filename, and it being desktop agnostic, makes it perfect for automated use.

scrot --focused --border --exec 'xclip -selection clipboard -target image/png -in $f; echo -n "$f" | xclip -selection primary' '%Y-%m-%dT%H.%M.%S_screenshot.png'

Even better would be to include the window title of the active window, but that would complicate matters as you need to filter out illegal characters and so forth. Still it can be done in a reasonable manner:

xdotool getwindowfocus getwindowname | tr -c '\40\60-\71\101-\132\141-\172' '_'

To have the full experience, I decided to use a shellscript. See screenshot.sh (click on the link to download).



# -------------
# Makes screenshots, optionally mails them.
# Evert Mouw, 2019-12-27

DEPENDENCIES="scrot xclip xfce4-screenshooter notify-send mail"
for D in $DEPENDENCIES; do
    if ! which $D > /dev/null; then
        echo "$D not found"
        exit 1

if ! [ -d "$STORE" ]; then
    MSG="$STORE is not a directory."
    echo "$MSG"
    notify-send --icon=error "screenshooter" "$MSG"
    exit 1

if ! [ -w "$STORE" ]; then
    MSG="$STORE is not writable!"
    echo "$MSG"
    notify-send --icon=error "screenshooter" "$MSG"
    exit 1

FG=$(xdotool getwindowfocus getwindowname | tr -cs '\60-\71\101-\132\141-\172' '_' | cut -c 1-33)
ME="$(whoami)@$(hostname -s)"

case $1 in
    OPTIONS="--select --freeze --line style=dash,width=3"
    OPTIONS="--focused --border"
    exit 0
    echo "Whut?"
    exit 1

scrot $OPTIONS --exec 'xclip -selection clipboard -target image/png -in $f; echo -n "$f" | xclip -selection primary' "$OUTNAME.png"

if [ "$?" -ne "0" ]; then
    MSG="Some error occurred.\nOUTNAME=$OUTNAME\nACTION=$1"
    echo -e "$MSG"
    notify-send --icon=warn "screenshooter" "$MSG"
    exit 1

OUTFILE=$(xclip -selection primary -out)
notify-send --icon=info "screenshooter" "Screenshot saved as $OUTFILE"

case $2 in
    # silently ignore
    echo "Screenshot" | mail -s screenshot -a "$OUTFILE" $EMAIL
    echo "2nd argument not recognized"
    exit 1

Keyboard shortcuts

I propose to use the same keyboard shortcuts as the free, open source Greenshot tool for Windows. In addition, I use the Super key (Windows key) to launch a custom dialog.

To keep consistency, I personally set the same keyboard shortcuts in XFCE.

xfconf-query --create --channel xfce4-keyboard-shortcuts --property "/commands/custom/Print" --type string --set "sh -c 'sleep 0.1 && /home/evert/bin/screenshot.sh region'"
xfconf-query --create --channel xfce4-keyboard-shortcuts --property "/commands/custom/<Alt>Print" --type string --set "/home/evert/bin/screenshot.sh active"
xfconf-query --create --channel xfce4-keyboard-shortcuts --property "/commands/custom/<Ctl>Print" --type string --set "/home/evert/bin/screenshot.sh full"
xfconf-query --create --channel xfce4-keyboard-shortcuts --property "/commands/custom/<Super>Print" --type string --set "/home/evert/bin/screenshot.sh custom"

Note that the first line contains a workaround (see also here) for a bug #616608 in scrot.

To see currently assigned PrnSrn keys:

xfconf-query -c xfce4-keyboard-shortcuts -lv | grep -i Print


This works for me. For a discussion on screenshooters, see e.g. on the forum of Linux Mint.

Editing screenshot.sh and making a screenshot using that script and scrot.

Deze blogpost werd in december 2022 overgezet van WordPress naar een methode gebaseerd op Markdown; het is mogelijk dat hierbij fouten of wijzigingen zijn ontstaan t.o.v. de originele blogpost.