This is a note for some use cases of xsnap, which I never can remember how to use them, exactly, even after five years.

1   Timestamp

This is the format I like to use:


-file "$HOME/tmp/ss/$(date +'%Y-%m-%d--%H:%M:%S.png')"

2   -region

Option value type GEOMETRY format: WxH+X+Y, for example:


xsnap -region 1280x720+2+20 -file screenshot.png

xsnap grabs 1280 by 720 pixels area at screen position 2, 20.

3   Full-screen

Using xwininfo to determine the screen size:


xsnap -file screenshot.png -region "$(xwininfo -root | sed '/\(Width\|Height\)/ {s/[ :a-z-]//gi;p} ; d' | tr '\n' ' ' | cut -d ' ' -f1-2 | tr ' ' 'x')+0+0"

The breakdown version:


xsnap -file screenshot.png -region "$(xwininfo -root |
sed '/\(Width\|Height\)/ {s/[ :a-z-]//gi;p} ; d' |
tr '\n' ' ' |
cut -d ' ' -f1-2 |
tr ' ' 'x')+0+0"