screenshots-loop.sh (709B)
1 #!/bin/sh 2 3 set -e 4 5 usage() { 6 echo "Usage: $0 {x11|mac} path/to/screenshots/directory" 7 } 8 9 if test $# -ne 2 || test "$1" = "-h" -o "$1" = "--help"; then 10 usage 11 exit 1 12 fi 13 platform="$1" 14 screenshots_dir="$2" 15 16 case $platform in 17 x11) screenshot_tool=scrot;; 18 mac) screenshot_tool=screencapture;; 19 *) usage; exit 1;; 20 esac 21 22 23 for i in `seq 100`; do 24 if test -e "$screenshots_dir/stop-screenshots"; then 25 break 26 fi 27 "$screenshot_tool" "$screenshots_dir/$(printf %03d.png $i)" || break 28 sleep 0.2 29 done 30 31 if test -n "$(find "$screenshots_dir/" -maxdepth 1 -type f -name '*.png')"; then 32 convert $(ls "$screenshots_dir"/*.png | sort) "$screenshots_dir/anim.gif" 33 fi 34 35 touch "$screenshots_dir/anim-done"