afc306fc |
1 | #!/bin/sh |
2 | |
3 | # Generate a screenshot from a puzzle save file. Takes the |
4 | # following arguments, in order: |
5 | # |
6 | # - the name of the puzzle binary |
7 | # - the name of the save file |
8 | # - the name of the output image file |
9 | # - (optionally) the proportion of the next move to redo before |
10 | # taking the screenshot. |
11 | # |
12 | # This script requires access to an X server in order to run, but |
13 | # seems to work fine under xvfb-run if you haven't got a real one |
14 | # available (or if you don't want to use it for some reason). |
15 | |
16 | binary="$1" |
17 | save="$2" |
18 | image="$3" |
19 | if test "x$4" != "x"; then |
20 | redo="--redo $4" |
21 | else |
22 | redo= |
23 | fi |
24 | |
25 | "$binary" $redo --windowid --load "$save" 2>/dev/null | { |
26 | read windowid |
27 | # I'm not sure why I have to do this sleep, since gtk.c does |
28 | # carefully redraw the window _before_ outputting the window ID, |
29 | # but nonetheless this script doesn't seem to be reliable without |
30 | # it :-/ |
31 | sleep 1 |
32 | xwd -silent -id $windowid | convert xwd:- "$image" |
33 | xkill -id $windowid >/dev/null |
34 | } |