About a month ago I switched from Ubuntu 14.04 LTS to Arch and I'm quite happy with this decision. However, I miss some features with my new distro, especially Shift+printscr which in Unity allows selection of a screen region to be captured.

I use i3 WM. So, my question is: how can I configure Unity-like screenshot behaviour to be able to snap screen regions or windows with a keyboard shortcut or something (without digging into window id and console stuff)?

share|improve this question

If you just need screen regions, use import, part of ImageMagick. If you call it without any arguments except the output filename, e.g.

import ss.png

it 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. You can also use it to grab screenshots of the whole display as

import -window root ss.png

and you can provide specific window id's to the -window option to screenshot a specific window.

share|improve this answer
    
Simple, perfect, just what I needed - and I didn't have to download another program. – Darren Haynes Mar 24 '17 at 23:06
up vote 6 down vote accepted

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.

Hope it would help somebody!

#!/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/"
share|improve this answer

have you tried scrot a, simple commandline screen capture utility

ref., : https://faq.i3wm.org/question/202/what-do-you-guys-use-for-printscreen/

share|improve this answer
    
Wow, after googling I realized, that scrot is actually capable of everything I need. Too weird I didn't find it by myself. Thanks, dude! – ddnomad Oct 1 '15 at 19:51
    
you can also use scrot -s to capture a specific region. run the command then click and hold then click on the second point, it'll create a file with date as filename in your current directory. – vimdude Jan 1 '17 at 19:13

First, install xclip, imagemagick and jq!

pacman -S imagemagick jq xclip

I have this line in my i3 config:

bindsym $mod+Print exec \
    import -window $( \
        i3-msg -t get_tree | \
        jq 'recurse(.nodes[]) | select(.focused).window' \
    ) png:- | \
    xclip -selection clipboard -t image/png

This will put a screenshot of the active window on your clipboard when you press mod (Window / Alt) + Printscreen.

i3-msg -t get-tree gets all windows from i3 as json, then we use jq to get the window id of the focussed window. We pass it to imagemagicks import command and pipe the result to xclip who will put it on the clipboard!

share|improve this answer

A very simple option if you have it installed or don't mind installing it is using xfce4-screenshooter and i3 config would be:

bindsym Print exec --no-startup-id xfce4-screenshooter

Caveat: although fairly lightweight there are some dependencies if you are not using any other xfce4 programs

share|improve this answer

Use maim. It's more actively developed and depends on slop which is way better.

Don't use scrot.  Its selection box corrupts and leaves an impression in the screenshot (also the box deforms when resizing) when used over an updating window (say htop).

share|improve this answer
    
(1) What is “slop”? (2) What, exactly, is it better than? (3) Why? – G-Man Nov 7 '17 at 22:17
    
1. Select operation, used to select window regions [github.com/naelstrof/slop] 2. It's better than scrot because it doesn't undergo selection box corruption (Try scrot over htop). 3. idk. – Hritik Nov 8 '17 at 16:41

I like shutter for its post-processing capabilities (hand-drawn red circles!) and comprehensive configuration options.

You can grab a screen region by running

shutter --select

You can set up key bindings in .config/i3/config like so:

bindsym Print         exec shutter --full
bindsym Shift+Print   exec shutter --select

It takes a second to load, so you may want to autostart it in the background:

exec shutter --min_at_startup

Shutter will be accessible via a tray icon then, which gives you many useful options beyond the above.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.