The i3 FAQ has migrated to https://github.com/i3/i3/discussions. All content here is read-only.
Ask Your Question
0

Screenshot of focused window

asked 2014-10-21 18:28:52 +0000

Kaligule gravatar image

I want to be able to do screen shots of the focused by pressing a button. Should be easy.

First try: scrot

(since it seems to be the most recomended tool for screenshots in i3wm)

Whole screen

bindsym XF86Display exec "scrot ~/Downloads/Screenshot%Y-%m-%d%H:%M:%S.png"

Works fine

Focussed Window

Well... Some people in the internet seem to think there is a -u flag for scrot but in the yum-installed Fedora version (0.8) there definitely is not. Bad luck.

Second try: ImageMagick

(since many people tell me it can do anything I want)

Whole screen

bindsym XF86Display exec "import -window root ~/Downloads/Screenshot$(date +%F%H:%M:%S).png"

The date is not as elegant as in scrot, works fine though.

Focussed window

Tricky. I don't know the id of the focused window. But there is a workaround:

import -window xwininfo | awk '/.*Window id:.*/ {print $4}' ~/Downloads/Screenshot$(date +%F%H:%M:%S).png

I can click on the window I want to screenshot and there we go. A bit of a hack (found here: http: //www .trueelena.org/computers/howto/screenshotswithimagemagick.html ), but anyway. Works in the console. But in i3config:

bindsym XF86Display exec "import -window xwininfo | awk '/.*Window id:.*/ {print $4}' ~/Downloads/Screenshot$(date +%F%H:%M:%S).png"

Doesn't work. I am asked to click on a window, but no screenshot is saved. I am not sure why.

Could someone give me a hand, please?

edit retag flag offensive close merge delete

3 answers

Sort by ยป oldest newest most voted
0

answered 2015-10-08 09:39:59 +0000

SpicyCat gravatar image

ksnapshot

Check my answer to another similar question

edit flag offensive delete link more
0

answered 2015-09-30 22:44:38 +0000

When I use:

$scrot --version
scrot version 0.8

you get the -u flag which:

-u, --focused use the currently focused window

and doing:

~$ scrot -u '%Y%m%d_%H%M%S.png' -e 'mv $f ~/images/shots/'

Does in fact create a screeshot of the currently focused window and sends it to the /shots/ directory.

For further reference -s:

-s, --select              interactively choose a window or rectangle
                               with the mouse

That is th option that I prefer

edit flag offensive delete link more
0

answered 2014-10-21 21:10:31 +0000

cee gravatar image

I rarely use screenshots.
But when I do, I use scrot, select the region I want and open gimp.
That all with one keyboard shortcut. What's not to love about i3 ;-)

bindsym Mod1+Print exec scrot -s -e 'mv $f /tmp/ && gimp /tmp/$f' --release

Or for the whole screen

bindsym Ctrl+Print exec scrot -e 'mv $f /tmp/ && gimp /tmp/$f'

Disclaimer:
The two lines are shamelessly taken from another entry in this forum.

edit flag offensive delete link more

Comments

This is ok, but doesn't solve the problem of screenshoting exactly 1 window. I don't want to select a region, but shoot the active window.

Kaligule gravatar imageKaligule ( 2014-10-22 08:33:37 +0000 )edit

Yes, that is true. But as I said I rarely use screenshots and so this is sufficient for me.

cee gravatar imagecee ( 2014-10-22 08:49:03 +0000 )edit

Question Tools

Stats

Asked: 2014-10-21 18:28:52 +0000

Seen: 1,203 times

Last updated: Oct 08