Timely screenshots in OS X

Silly thing I did this weekend: I wanted to take some screenshots of a game I was playing, but pressing F12 (the Steam shortcut to take a screenshot) while pressing all other keys isn’t that easy. So I came up with this very small script:


while True; do
	sleep $1
	file=`date "+%Y%m%d-%H%M%S"`
	echo "Capturing $file..."
	screencapture -x -tpng $file.png

I know I could use something like -T$1 to make screencapture wait till taking the screenshot instead of using sleep $1 but then the name won’t match the time of the screenshot (not that that would be a big problem, but I’m that kind of anal retentive).