How can I easily make screenshots of screen regions on Arch Linux with i3 WM?
You can use import
, part of ImageMagick.
Capture a region
This will change your cursor into a crosshair and when you click and drag to form a box, that box will be saved as ss.png
.
import ss.png
Capture whole display
import -window root ss.png
You can also replace the word root
with the window id to capture a specific window.
It's been a long time since I'd asked this question and it looks like it's helpful for some of the users. So I provide my own script for making screenshots with xclip
and imagemagick
packages.
First of all, install the above mentioned dependencies. Then you can do whatever you want with the script below. It supports making a screenshot of a whole screen or a screen region and also it automatically copies a screenshot to a clipboard so you can paste it everywhere (e.i browser or Telegram messenger).
A couple of not so hard to come up with hacks would add a support for capturing specific windows and toggle copying part.
#!/usr/bin/env bash
# screenshots stuff
# TODO: docs
function help_and_exit {
if [ -n "${1}" ]; then
echo "${1}"
fi
cat <<-EOF
Usage: scregcp [-h|-s] [<screenshots_base_folder>]
Take screenshot of a whole screen or a specified region,
save it to a specified folder (current folder is default)
and copy it to a clipboard.
-h - print help and exit
-s - take a screenshot of a screen region
EOF
if [ -n "${1}" ]; then
exit 1
fi
exit 0
}
if [ "${1}" == '-h' ]; then
help_and_exit
elif [ "${1:0:1}" == '-' ]; then
if [ "${1}" != '-s' ]; then
help_and_exit "error: unknown option ${1}"
fi
base_folder="${2}"
else
base_folder="${1}"
params="-window root"
fi
file_path=${base_folder}$( date '+%Y-%m-%d_%H-%M-%S' )_screenshot.png
import ${params} ${file_path}
xclip -selection clipboard -target image/png -i < ${file_path}
And here is my reference shortcuts for an i3wm
to make use of this script:
# take a screenshot of a screen region and copy it to a clipboard
bindsym --release Shift+Print exec "scregcp -s /home/ddnomad/pictures/screenshots/"
# take a screenshot of a whole window and copy it to a clipboard
bindsym --release Print exec "scregcp /home/ddnomad/pictures/screenshots/"
Flameshot is a decent alternative.
bindsym Print exec flameshot full
bindsym Shift+Print exec flameshot gui
You can use option -p /path/to/directory
to skip selecting the save directory.