The i3 FAQ has migrated to https://www.reddit.com/r/i3wm/. All content here is read-only.
Ask Your Question
4

What do you guys use for "printscreen"?

asked 2012-07-04 12:03:26 +0000

I am running Linux on a Mac (forgive me, lol), and I am horrified with the fact my notebook does not have a printscreen button, then I have to bind it with some nasty key I hardly remember which one is.

Besides that problem, I was wondering what do you use to capture a screenshot with i3?

I am huge fan of shutter, but it does not work in i3 well (only selection works, the rest complains of "Keyboard could not be grabbed", which looks like a problem because of the mac keyboard, I'd guess).

I heard in the mailing list about KScreenshot, and others go deeper with xwd...

What is your best choice for i3?

edit retag flag offensive close merge delete

Comments

I just set up shutter yesterday and it's working just fine for me. I am not sure how I can assign a keyboard shortcut. Other than shutter, I don't know of anything comparable. Post-editing screenshots in Picasa just grew too annoying. EDIT have to retract above. Shutter only works with Selection.

lkraav gravatar imagelkraav ( 2012-07-04 14:08:17 +0000 )edit

same for me! :-) I am trying to reach Shutter's developers for some help on this... https://bugs.launchpad.net/shutter/+bug/1021996

bruno.braga gravatar imagebruno.braga ( 2012-07-07 02:29:27 +0000 )edit

Note that "keyboard could not be grabbed" can be fixed by using `--release` in the i3 binding.

scy gravatar imagescy ( 2014-02-11 09:30:37 +0000 )edit

The `--release` switch does not seem to exist anymore in current versions (neither in 0.90.1 from offician nor in 0.93 from ppa). Or do I get something wrong? I tried `bindsym Print exec shutter --release`. EDIT: Okay, the `--release` has to be placed right after bindsym. But the error still occurs!

mschaefer gravatar imagemschaefer ( 2014-08-20 08:24:40 +0000 )edit

10 answers

Sort by ยป oldest newest most voted
4

answered 2012-07-04 13:53:54 +0000

Klaas gravatar image

updated 2012-07-04 13:56:13 +0000

I like scrot. It is unmaintained but works (for my applications). It has some options, such as -s to interactively select a window/rectangle, or -d for a delay and more.

edit flag offensive delete link more

Comments

yeah, works great! perhaps you could bind keys to its commands as well, and make it easily accessible, right? Or, do you always hit it from command-line?

bruno.braga gravatar imagebruno.braga ( 2012-07-07 03:42:41 +0000 )edit

Well, I only need it every other month or so - at the moment. Binding keys of course works with the i3 bindsym directive.

Klaas gravatar imageKlaas ( 2012-07-12 10:28:09 +0000 )edit

http://itnihao.blog.51cto.com/1741976/914446 it solves some problems during installation.

diablo465 gravatar imagediablo465 ( 2013-10-17 05:41:26 +0000 )edit
2

answered 2013-07-24 05:21:03 +0000

avk gravatar image

updated 2013-07-24 05:25:00 +0000

'import' from ImageMagic works only if you don't have container widnows. So, on plain layout it works well, but in complicated situation it fails and produces blank image.

I prefer that my screenshot utility automatically places resulting image filename into my clipboard buffer. Here is my small script which does all of that (all my utilities link):

#!/usr/bin/env python
# -*- coding: utf-8 -*-

""" Use in i3wm with:
Save as screeshot.py somewhere into your PATH
bindsym --release Print exec --no-startup-id screenshot.py
"""


import os
from subprocess import Popen, PIPE
from tempfile import NamedTemporaryFile

SCREENSHOT_UTILITY = '/usr/bin/scrot -s' # /usr/bin/import

def feed_xclipboard(str):
    pipe = Popen("xclip -sel clip", shell=True, stdin=PIPE).stdin
    pipe.write(str)
    pipe.close()

def import_screenshot():
    filename = NamedTemporaryFile(
        suffix='.png',
        prefix='screenshot_',
        dir = os.path.expanduser('~/tmp'),
        delete=False).name
    p = Popen(SCREENSHOT_UTILITY + " " + filename, shell=True)
    sts = os.waitpid(p.pid, 0)[1]
    return filename


if __name__ == '__main__':
    screenshot = import_screenshot()
    feed_xclipboard(screenshot)
edit flag offensive delete link more
2

answered 2012-07-27 21:40:31 +0000

BroX gravatar image

scrot, with the following in i3/config:

# scrot & gimp - root
bindsym Print exec scrot -e 'mv $f /tmp/ && gimp /tmp/$f'
# scrot & gimp - select window or rectangle
bindsym Mod1+Print exec scrot -s -e 'mv $f /tmp/ && gimp /tmp/$f'
edit flag offensive delete link more

Comments

thanks, I'm not sure why one day `import` works, one day it doesn't. Today the force is with `scrot` :)

kevin gravatar imagekevin ( 2012-10-03 08:34:24 +0000 )edit

with `-s` does not work for me when calling by hotkey, without one and with one, but from command line, all is fine. Any ideas?

ul gravatar imageul ( 2014-01-24 09:07:58 +0000 )edit

@ul: Yes, you need to use `--release` in the binding. Else, i3 still owns your input when scrot gets called, and scrot simply exits.

scy gravatar imagescy ( 2014-02-11 09:28:11 +0000 )edit

@scy Thank you! Now my PrtSc is perfect ;)

ul gravatar imageul ( 2014-02-13 08:02:34 +0000 )edit

Thanks, it works after puting --release

diablo465 gravatar imagediablo465 ( 2014-02-19 04:08:42 +0000 )edit
1

answered 2015-09-11 12:34:01 +0000

SpicyCat gravatar image

ksnapshot

Work out of box and it is the best.

It has a delay feature. It can delay several seconds before taking snapshot. This feature is really useful when you need take screen shot of some menus or tooltip.

I don't see any other tool supporting this feature.

I don't understand why so many people here use script and command line tool to take screenshot. What is the merit? Flexible? Configurable? But what you do by your scripts is the same with what I do by ksnapshot image description

edit flag offensive delete link more

Comments

Same. Sure there are ways of implementing its features that would give you more minimalist cred but I'm laaazy. I use lots of KDE apps with i3 which people find ironic.

dd0 gravatar imagedd0 ( 2015-09-20 17:04:18 +0000 )edit
1

answered 2012-07-11 09:05:45 +0000

kevin gravatar image

I personally use import from the Image Magick package.

A little while ago I used gnome-screenshot, but it recently stop working on my system, maybe because of a dist update, or an i3 update, I'm not sure.

edit flag offensive delete link more
1

answered 2012-07-24 19:53:55 +0000

loblik gravatar image

updated 2012-07-24 19:59:51 +0000

I have a script which takes a screenshot using import from imagemagick. It's able to shot whole root window or currently focused window. That depends on the only one argument it takes.

screen.sh root
screen.sh active

At the top of the script there are to variables which control its behaviour. The SCREEN_DIR is a directory where you want to save your screenshots. And the SCREEN_PROMPT defines whether you want to be prompted for name of screenshot by i3-input. If you don't then this variable must not be set at all.

You can export these variables from your startup scripts to have settings separated from script itself.

The screenshot is saved in SCREEN_DIR under name in format NAME-YEAR-MONTH-DAY_HOUR-MIN-SEC.png where NAME is string typed in to the i3-input. If prompt is disabled or empty string is given then WM_CLASS of window is used or just "window" if WM_CLASS is not set. In case of root window screenshot NAME is "root".

And finally symlink named 'last' pointing to last taken screenshot is created for easier lookup.

#!/bin/bash

SCREEN_DIR=~/screenshots/
SCREEN_PROMPT=1

window='root'

case $1 in
  root)
    window='root';;
  active)
    window=`xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)" | cut -d' ' -f5`;;
esac

[ ! -z "$SCREEN_PROMPT" ] && \
  name=`i3-input -P 'screen-name: ' | sed -n '/command = /s/command = //p'`

if [ -z "$name" ];then
  if [ $window == "root" ];then
    name='root'
  else
    name=`xprop -id $window | sed -n '/WM_CLASS/s/.* = "\([^\"]*\)".*/\1\n/p'`
    [ -z "$name" ] && name='window'
  fi
fi

filename="$name-`date +%Y-%m-%d_%H-%M-%S`.png"

import -border -window $window "$SCREEN_DIR/$filename"


ln -sf "$filename" $SCREEN_DIR/last

exit

In i3 config just create simple binding.

bindsym Print exec screen.sh root
bindsym Mod1+Print exec screen.sh active

Note that if you take second screenshot during single second the previous one taken in that same second gets overwritten since there is no check for this case. So if you like to use printscreen to make movies you should check for this.

edit flag offensive delete link more

Comments

Not bad!!! :-)

bruno.braga gravatar imagebruno.braga ( 2012-08-03 01:13:36 +0000 )edit

thanks for this!

okubax gravatar imageokubax ( 2013-07-11 07:24:58 +0000 )edit

I am having some issues with import for floating windows (tooltip, etc). and scrot solved my problem.

bruno.braga gravatar imagebruno.braga ( 2013-07-12 03:11:11 +0000 )edit

I'm using ImageMagick's `import` command in combination with `Zenity`, but so far I haven't figured out how to restrict the 'root' window to just a single output (like HDMI1). I can capture a particular window, or the root with all of the outputs, but not just a single output.

GenghisKen gravatar imageGenghisKen ( 2015-08-19 15:17:57 +0000 )edit
0

answered 2015-09-03 14:47:53 +0000

Miro gravatar image

I like scrot, because it's simple, and it can do everything I need (bindings of my configuration):

  • fullscreen screenshoot (PrnScr)
  • window screenshoot(Alt + PrnScr)
  • select windows screenshoot(Alt + Shift + PrnScr)

Combined with date command it can create screens with timestamp in filename, which can be edited later.

Here is the config:

bindsym Print exec scrot $HOME/Pictures/ScreenShoots/`date +%Y-%m-%d_%H:%M:%S`.png
bindsym Mod1+Print exec scrot -u $HOME/Pictures/ScreenShoots/`date +%Y-%m-%d_%H:%M:%S`.png
bindsym Mod1+Shift+Print exec scrot -s $HOME/Pictures/ScreenShoots/`date +%Y-%m-%d_%H:%M:%S`.png
edit flag offensive delete link more
0

answered 2012-07-30 16:02:09 +0000

jonyamo gravatar image

I am using i3 on CrunchBang which was already set up to use xfce4-screenshooter, so I just stuck with it and it has been working perfectly for my needs.

I set up a keybind to call it with Mod4+s :

bindsym Mod4+s exec xfce4-screenshooter
edit flag offensive delete link more

Comments

I second xfce4-screenshooter. Works good has few dependencies.

topernic gravatar imagetopernic ( 2014-10-13 15:20:04 +0000 )edit

I third xfce4-screenshooter :D In addition to having all the normally required features (i.e. save an image of (1) entire screen, (2) active window, or (3) selected area), it can also upload the image to a few web services without the bother of creating an account with the said services.

denzen gravatar imagedenzen ( 2015-09-07 05:28:18 +0000 )edit
0

answered 2014-09-29 13:58:34 +0000

Sam73 gravatar image

updated 2015-09-10 13:59:39 +0000

I use a mix of scrot and python to load directly the screen capture into clipboard.

In my config I got

bindsym Print exec scrot -e 'pyclip $f'
bindsym Mod1+Print exec scrot -s -e 'pyclip $f'

and got this small python script to load it into clipboard that I took from superuser The trick is that your program need to stay active as long as the clipboard contains the image.

#!/usr/bin/env python
import gtk 
import sys

count = 0
def handle_owner_change(clipboard, event):
    global count
    print 'clipboard.owner-change(%r, %r)' % (clipboard, event)
    count += 1
    # On my new computer, I had to push counter to 2 because the event is triggered immediatly and script goes out with the buffer. This version keeps the buffer until next screenshot.
    if count > 2:
       sys.exit(0)

image = gtk.gdk.pixbuf_new_from_file(sys.argv[1])
clipboard = gtk.clipboard_get()
clipboard.connect('owner-change', handle_owner_change)
clipboard.set_image(image)
clipboard.store()
gtk.main()
edit flag offensive delete link more
0

answered 2015-04-07 16:26:21 +0000

Similar solution than lobik using perl with 4 options:

bindsym $mod+Print exec Print_Screen root 
bindsym --release $mod+Shift+Print exec Print_Screen area
bindsym $mod+Mod1+Print exec Print_Screen delay
bindsym $mod+Control+Print exec Print_Screen window

This is the script, sending a message when the screenshot is taken.

#!/usr/bin/env perl 
# Info {{{
#  DESCRIPTION: Print Screen
# }}}

# use {{{
use strict;
use warnings;
use experimental 'smartmatch';
use v5.20;
# }}}

# Variables {{{
my @print_option = qw/root area window delay sequence/;
my $timestamp = `date +%Y_%m-%d_%H-%M`; 
chomp $timestamp;
my $target = "/home/mimosinnet/Dades/Imatges/ScreenShots/$timestamp.png";
my (@args, $window);

die "Usage: \n Print_Screen root|area|window|delay \n" unless 
    (scalar @ARGV == 1) and ($ARGV[0] ~~ @print_option);

# }}}

# Select options {{{
for ( $ARGV[0] ) {
    if ( /root/   ) 
        {   @args = ("import", "-window", "root", $target) }
    if ( /area/   ) 
        {   @args = ("import", $target) }
    if ( /window/ )
        {   $window = `xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)"`;
            ($window) = $window =~ /(0.*$)/ ;
            @args = ("import", "-window", $window, $target) } 
    if ( /delay/  )
        {   sleep 5;
            $window = `xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)"`;
            ($window) = $window =~ /(0.*$)/ ;
            @args = ("import", "-window", $window, $target) } 
};
# }}}

# Debugging
# foreach (@args) { print "$_ "; } exit;

system(@args) == 0 or die "unable to do the screenshot because of: $?";

@args = ("xmessage", "-nearmouse", "Captura de Pantalla Feta");
system(@args) == 0 or die "unable to show message because of: $?";
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2012-07-04 12:03:26 +0000

Seen: 15,821 times

Last updated: Sep 11