Ever thought it handy to be able to take a picture of whoever is using your computer? Great for security, particularly if your laptop gets flogged.
Well I’ve just uncovered a neat solution for my MacBookPro and Mac Air using DropBox (which incidentally I am in love with!), the built-in iSight Cam and a little command line app called iSightCapture.
iSightCapture is simply called from the command line to take a snapshot photo using the iSight cam and saves the image as a file. This makes automation easy. I did the following (assuming you are a DropBox user, if you are not you should be!):
1. Download iSightCapture and stick it in the folder in /sbin.
2. Create a basic perl script to call the iSightCapture app (see below).
3. Create a launchd plist to call this script at login time, plus at 4 hour intervals thereafter (see below).
I chose perl for no reason other than I had another script that I could quickly modify to suit – you can use anything, obviously.
The perl script does two main things.
1. Creates a file name for the image using the current date and time, so it is unique (unique enough anyway).
2. Specifies the path that the image will be saved. In my case a DropBox photos folder.
The great thing about DropBox is it automatically copies any new/modified files in it’s patch up to the cloud, almost instantly. This is perfect for this application.
The two scripts are as follows:
Perl (save as iSightSnapshot.pl):
#!/usr/bin/env perl # get date/time my ($sec,$min,$hour,$mday,$mon,$year, $wday,$yday,$isdst) = localtime(); # tweek the date/time my $month = $mon + 1; #Jan = 0 for $mon my $fullyear = $year + 1900; #year offset by 1900 if ($month < 10) { $month = "0$month"; } if ($mday < 10) { $mday = "0$mday"; } # generate the command including the image filename and path, customise the path to suit your system $command = 'isightcapture /Users/ben/Dropbox/Photos/Snaps/mbp/snaps_'.$fullyear.$month.$mday.'_'.$hour.$min.$sec.'.jpg'; #run backup command system ("$command");
Launchd:
(saved in /Library/LaunchAgents and customise the path to your perl script)
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>ShapshotAtStart</string> <key>ProgramArguments</key> <array> <string>/Users/ben/Documents/iSightSnapshot.pl</string> </array> <key>RunAtLoad</key> <true/> <key>StartInterval</key> <integer>14400</integer> </dict> </plist>
So there you have it, a very quick and easy way to add some security to your system.