For fun, I’ve set up my laptop to take screenshots and pictures from the webcam every hour. These images are stitched together and dropped in a folder on my disk. I haven’t really found some great usage for this yet but it is quite fun to look back at every now and then.

The script produces images like the ones below.


I use a couple of programs to acheive this result. First, to setup the cron job I use this line

00 * * * * source /Users/jontelang/.bash_profile; snapimage;

Here, snapimage is a method that I have made that is inside my bash profile. So I tell the cronjob to use this file, then I call the method.

The method itself looks like this:

function snapimage(){
  cd /tmp
  /usr/sbin/screencapture -x screensnap.png
  imagesnap -w 2 camerasnap.png
  filename=$(date +%Y-%m-%d___%H.%M.%S.png)
  /usr/local/bin/convert +append camerasnap.png screensnap.png $filename
  mv $filename /Volumes/FUJITSU/Automatic-Images-Via-Imagesnap/$filename

The actual flow in the script is pretty straight forward so I won’t bother to explain. But the things used needed some scavanging for. imagesnap is a downloaded program that takes images from the webcam. convert is a progam in the ImageMagick suite. screencapture was bundled with OSX as far as I know.

Sometimes it is fun to see what happened while you were gone.