Subscribe

2006-06-21

So you have this iSight camera built into your Mac and you want to make it take images on demand. My first thought was to get Automator to do it all, however Automator does not have access to the camera at this stage. As soon as Automator has a camera action then the task will become much more simple and you can toss out the mess of scripting below.

What follows is a number of experiments to take capture iSight images at set times. The methods use a neat piece of software from Axel Bauer at intergalactic. The software is run from the command line (universal binary) and allows you to take a picture as long as the camera is working and not in use.

Experimenting with AppleScript

I created a folder called /Applications/snapme where I placed all the script files, including Axel's isightcapture program. After looking around I noted an example script in AppleScript which I decided to improve upon. Thanks to some excellent tips from Michael Henley who pointed me at the shell script reference for AppleScript.

Remember to open a terminal session and chmod the saved shell script file so you can execute it. You may have to rename snapme.txt to snapme if you used TextEditor.

Terminal : command promptchmod 755 /Applications/snapme/snapme

I also placed a link in the path so I could run it from anywhere on the command line. You don't need to do this for Automator to work. But if you want to type "snapme" at the terminal prompt then this is one way to set up.

Save as App called "snapme" {.app} in the /Applications/snapme folder. You should now be able to click on the snapme app and have a pic saved in your pictures folder with date-time in the name. You can alter the shell script above to change the destination path and/or the output filename.

Note that you can tell AppleScript to create an application under "File", "Save As". Change the "File Format:" to "application", untick "Startup Screen" and tick "Run Only".

cron

After a security update, cron was unable to run a shell script calling isightcapture properly - the captured image fails to be written. However, you can create a cron job to run an applescript app which issues the isightcapture shell command (such as snapme.once above). You could also try Lingon to run the script via launchd.

cron is a *nix command that can schedule repeated program calls for you. This is all very advanced so proceed with caution, chance to mess your system up is quite high. We want cron to run our shell script at specified times. First let us examine the cron command.

cron file formatmin hr day month dayOfWeek program0-59 0-23 1-31 1-12 0-6(0=Sunday)example:20 1 * * * /Applications/snapme/snapme.once.app run every morning at 1:20am0 2 1 * * /Applications/snapme/snapme.once.app run every morning at 2:00am on the 1st of day of every month0,15,30,45 9-18 * * * /Applications/snapme/snapme.once.app run every 15 minutes from 9am to 5:45pm

Note that if cron receives output from the script then it will email that output to you.

In OS X, "crontab -e" will invoke the text editor known as vi which is really not the editor of choice for most Mac users. vi is hard core.

Terminal : command promptcrontab -e

Here's the few simple commands you want: tap "A" to get into insert mode, edit your text with only one of the crontab entries such as

0,15,30,45 * * * * /Applications/snapme/snapme.once.app

then tap "ESC" to get out of insert mode.

WARNING: if you have that really cool speech recognition app going you are going to have to shut it down to stop it from absorbing the ESC char on you.

Type ":wq" and tap enter which will write and quit.

MoreThere is a lot of complicated scripting going on here. I am assuming a level of competence that you really shouldn't have to have.

2006-06-18

Thanks to putting in a tonne of overtime hours for a particular project, they agreed to fund my purchase of any equipment that I might need for home use. Hurrah! I suggested and have received a sweet 20inch Intel Core Duo iMac. Which explains the lack of pretty much everything else that I have been doing lately. The shipment was delayed a couple times, the people at Infinite Systems were quite good about it and kept me updated - I tried not to contact them too often as there were deadlines that would preclude any lustful fawning of a new computer. The last delay was the iMac missing the plane to Australia (dopey Mac) and so arrived late on a Friday afternoon. The store was good enough to contact me about the iMac's delivery and gave me the choice of picking up the system that afternoon or waiting for it to be delivered on Monday. What choice was that?! I will pick it up! The service guy was installing the extra RAM when I arrived and whatever other voodoo they have to perform prior to release. Then it was mine! All mine! Much bigger than I thought it would be, and heavier. But then this is no laptop - this is a full on desktop with a honking big screen. Quite a simple matter of loading the box into the back of my Jazz and buzzing home. Setup was a breeze; one power cable, plug in keyboard and mouse. OK, I might have had a little problem finding the power button, thankfully Donna spotted it very quickly. Surprisingly little documentation for a computer, operating system and all the bundled goodies found in the included iLife package. First app executed was Garage Band. Glee! Donna and I rapidly put together a slick sounding podcast ... light on the content, but fun to make. Check out Front Row movie trailers, then I get down to the task of Boot Camping.

Having had a much older G3 iMac for some time now, I am not completely a newbie to the OS X world. I had OS 9 upgraded to OS X (10.3) on this old computer and noted the improved performance. Even though the old iMac was operating below 400MHz, the system speed is more than adequate to operate as a slick web browser.

The Intel iMac operates VERY much faster. After messing around with some of the neat features of Front-Row and iLife, I decided to forsake my old Microsoft Windows AMD 2200 and cart everything over on the iMac. Sweet joy!

This journey of "switching" systems has not been without some pitfalls and hiccups.

Run Microsoft Windows on an Apple MacI would not really have made this journey if I was forced to forsake the Microsoft Windows environment completely. Fortunately with the new Intel based Apple computers, you can install and run Windows software. Currently this is via one of two methods: Boot Camp which allows you to boot the computer into Microsoft Windows or Apple OS X. Alternatively you can purchase Parallels which will allow you to run Microsoft Windows within an Apple OS X window; quite efficiently. I have setup both and have been quite surprised how quick and easy it is. Note that you will have to have a licensed copy of Microsoft Windows to do this (you can't use Dell branded OEM Windows, so I hear). I also recommend setting up VirtueDesktops so you can put Microsoft Windows on another desktop and jump between your main OS X screen and the Parallels Microsoft Windows Screen. Slick!

iLifeAll Apple computers come with iLife '06 which contains so many goodies that I will just have to direct you to the Apple page to show you what can be done. Software to help you make music, design web pages, edit and share photos, edit video, create DVDs, purchase and play music. Simple (ish) and so very much fun++. As previously stated, I have already created a podcast file and will host it somewhere for people to check out. I will be co-opting some of you in for future productions.

I had some trouble with Garage Band, the audio that I recorded suddenly became corrupted, unsure what I did but problem was something to do with moving/resizing a track and/or exporting. The sound became all digitally bubbly stuttering. Frustrating. The podcast was still moderately OK and I released a sample to friends. Not completely satisfied I started to explore the file system and found that Garage Band creates a folder for each of its projects. Inside the folder are several other folders and I managed to locate the aif audio file of the original recording. I simply reimported that file into the podcast and the sound was repaired - hurrah. All of this had to be done in Terminal using unix commands such as "cd", "ls" and "mv". Fine for me as I grew up with this stuff, but pity the poor ma & pa with a Mac as their first computer trying to figure that out; let's hope they never need to.

FireWire is hot!I don't know what Apple does with FireWire but DAMN it is very fast. In theory USB-2 should be better at 480Mbits/sec compared to 400Mbits/sec of IEEE-1394 (FireWire) but I seem to actually get the full 50 Megabytes a second on my Vantec hard drive enclosure where as Windows seems lucky to get 10 Megabytes per second sometimes. Not that I have officially timed any of this, but the difference is obvious to me; FireWire is much faster.

Just coolTap F12 and you are in Widget world, go install some more.Tap F9 and Expose shows you all the software you have open at a glance.Cmd+Opt+8 turn on the zoom; Cmd+Opt+= zoom in; Cmd+Opt+- zoom out; Cmd+Opt+Ctrl+8 invert screen coloursFind heaps of other keyboard shortcuts by install the xcuts widget.Front row turns your Mac into a media centre of sorts; a great way to navigate media, browse movie trailers.Automator scripting is very cool indeed once you figure your way around; simplifying mundane tasks very quickly.Speech recognition is awesome; I wasted most of a day playing with this.Not for everyone but Terminal connects via SSH so easily to my Linux machines.Spell check seems to be everywhere, even in web forms.Apache web server built in, "System Preferences" -> "Sharing" and tick "Personal Web Sharing".Built-in firewall.

OfficeYes, you can go out and buy Microsoft Office for Mac, but it isn't Unisversal, however Rosetta does quite a good job and runs the PPC version at a reasonable pace. A demo version of MS Office was already installed on the iMac and it operated quite slickly. You could also just use Office for Windows in a Parallels window running Microsoft Windows. Or you can investigate the alternatives that Apple provide such as iWork or the free Open Office. I have yet to settle on what to do here, I will definitely try Open Office but I am not enamoured of the X11 interface.

Screen issuesI am having some problems with my screen. It is only minor at this stage, and apparently pretty much isolated to me as I can't find anyone else on the net having the same issues. Apple have been very helpful and are eager to investigate / fix / replace, but I want to give this machine a little more time to burn in before I send the thing off for repairs.

Dodgy USB interfacingThis is an OS X problem as far as I can tell. I have heaps of drives that I plug into my iMac, generally everything works fine but every now and again I will have issues where OS X will disconnect the drive for no particular reason while copying, will mess up folder names on FAT partitions in Finder but not on the actual drive (reboot solves). But it all works smoothly when I am in WinXP under boot camp.

Colours not stickingI can assign folders different colours for the background in Finder, but my Applications folder changes the colour to something else every fricken time. Honestly this is a pretty basic function of OS X, I would have thought this would be running smoothly.

Speech/Speakable Items commands going nutsI love Speakable Items. If you add an item that you do not want you can manually remove the file using finder by going to the /Library/Speech/SpeakableItems folder. In the "Commands" section under "Application Switching" the "Quit from ..." and "Switch to ..." items list has a huge number of duplicates on my setup that is getting larger every time I speak to my Mac.

Finder errorsApart from the USB issues and colour problems, occasionally in columns view when I scroll around, the graphics offset for one or more of the columns appears to get out of step with itself. I can see two folders of the same name, I click on one and it will change its name to what it should have been.

Wireless NetworkMy wireless network functions quite well for the five systems that access it. However the iMac refused to connect even though it could see it. Eventually I found an option screen which allowed me to tell the iMac to not be so fussy and it connected up straight away. When I got organised enough to write down my set up routine ... I could no longer find the option. Damnit. So the tip for people who are having troubles is : look elsewhere (the menu bar, system preferences, internet connect. The network socket connected instantly.

Safari don't like this pageVery very few times a page will not load correctly in Safari. I would say it is about the same as Firefox. Otherwise - I really do like Safari and am currently using it as my browser of choice. Maybe I will load Firefox later when the next version comes out. I miss AdBlock.

PrintingI have a awesome Lexmark E230 hanging off a Windows XP Home machine in my computer room. OS X has the right printer driver, sees the shared printer but comes up with "NT_STATUS_ACCESS_DENIED" when you explore around system preferences. There are a number of web pages with useless information telling you to hold down Alt/Option when in the (non-existent) Printer Centre to get an advanced option; but these web pages neglect to tell you specifics and are worse than completely useless. Fortunately Scott Hurring gives quite a good guide to get things going. To add a little to the frustration I was using Windows XP Home on my printer server, I had to add a new user with password (not admin) to allow my Mac to connect to the printer.

The printer setup should have been MUCH easier to do, and apparently is intended to be so, however the installation process is quite broken. Grrrrrrr!

HangsOh yes, don't believe the hype; OS X does hang. Only three times for me so far, and I have to point out that I am truly messing with the system here. Once when BackupList was using rsync to copy about 16Gig to my firewire drive, once when I somehow accidentally opened all my bookmarks in Safari while it was loading a huge complex web page, and one time where I wasn't doing anything in particular. No mouse movement, so I just held down the power button until the system switched off. The restart took ages, so I am assuming that there is some sort of repair/integrity checking going on.

NagwareOne of the programs below (I suspect VirtueDesktops or Adium) keeps trying to install "Smart Crash Reports" nearly every time I boot up, and even tho it has a "Don't Ask Me Again" checkbox that I tick every time, it keeps fricken' asking me. I will never ever install this software because of that. I sent an email of displeasure to the punks that wrote "Smart Crash Reports", but have not yet received any reply.

OverallI would say that OS X feels like Windows 95 did when I was exploring it in the early days. Very cool interface but niggling problems abound. Again this is only because I run around exploring all these things. I'm sure the normal user just sits back and uses the common items without any problems. But then wouldn't they do that in Windows XP too? Don't get me wrong, I'm here to stay, it is just that I am not going to fool myself into thinking this is all fairy land perfect.