how to map the printscreen button

Hello, I’m trying to accomplish this:

when I hit the printscreen button on my keyboard, I want to take a screenshot (using scrot)
when I hit alt+printscreen, I want to take a screenshot of the active windows
when I hit ctrl+printscreen, I want to take a screenshot with a delay of 5 seconds (scrot -dc 5?)

I would like to save the screenshots in ~/screenshots and the name should be something like yearmothday-hourminutsseconds-resolution.png.

is that possible?

I figured I should use something like (copied this from my fluxbox config)

Key Print A Exec exec scrot -d 4 'something.png';xmessage 'screenshot saved!'

However this doesn’t seem to work. I also tried Key Print A CM...
but that also didn’t seem to work well.

any ideas?

Johan

I got that… this work but with no xmessage displayed…

Key Print   A    M  Exec exec scrot -d 4 ~/something.png ; xmessage 'screenshot saved!'

So I wrote a little shell script :
~/.fvwm/scripts/xscrot

/#!/bin/sh
scrot -d 4 ~/something.png
xmessage 'screenshot saved!' &

I call it like that : Key Print A M Exec exec ~/.fvwm/scripts/xscrot

And now I got the xmessage…

But for the key without modifer, i got nothing…

ok, thanks, that worked.
the same thing can be used for a delayed screenshot.

How do I take a screenshot of a window? maybe with the same thing used for the thumbnailthing in fvwm?

Johan

You can use “ThisWindow” – it’s an fvwm command.

– Thomas Adam

Just to let you know that I found the things that I wanted using This link (in dutch).

For those that don’t speak dutch (propably most of you), I used scrot -b -s %d-%m-%Y.png for taking screenshots of windows.

I mapped the printscreen key to a simple scrot command and alt+printscreen to the above command, and ctrl+printscreen to a scrot -d 5 screenshot.png to make a 5 seconds delayed screenshot.
Works great.

to make it even better, I emerged xosd and added on-screen-display-messaged to let me know where to find the screenshot. In case of the delayed screenshot, I use 2 osd-messages, 1 before the scrot -d 5 and 1 after, the first stating ‘screenshot is about to be taken’.
this is displayed 5 seconds, then te screenshot is taken and then I’m notified where to find the shot.

for those who want to know how to use the OSD-messages, use something like this:

echo "Hi, I'm here!"|osd_cat -f '-b&h-lucida-bold-r-normal-*-*-240-*-*-p-*-*-*' -c rgb:00/ff/00

To use it combined with a screenshot, just use |, e.g. put this in your .fvwm2rc to make screenshots with your printscreen key (all in 1 line!)

Key Print A A Exec exec scrot ~/.fvwm/screenshots/screenshot.png|echo "Screenshot stored in ~/.fvwm/screenshots/"|osd_cat -f '-b&h-lucida-bold-r-normal-*-*-240-*-*-p-*-*-*' -c rgb:00/ff/00

Note that you need scrot and xosd for this to work.
do ‘man xosd’ to add other options to osd_cat such as positionning

Hope this helps.

In case someone prefers another program, try one of the programs mentioned in the link: import (imagemagick) or xwd.

Hmm, that link basically describes the various screenshotting commands available on most *NIX systems (now you non Dutch-speaking people know it), well, I’m at least happy that they finally managed to do something constructive.

Also, I found that this is working too :
Key Print A N Exec exec scrot -d 1 ~/screensnapshot/screensnapshot_“$(date)”.png
Key Print A M Exec exec scrot -d 1 ~/screensnapshot/tempscreensnapshot.png
Key Print A CM Exec exec scrot -d 1 ~/something.png

A/ -d 1 is necessary (0 not working)

B/ the " " have to be just front of “$(date)” only

Cheers