Make iPhoto open for your Camera not your iPhone

The contents of this article may be out of date. It has been archived and will no longer be updated, comments are closed and the page is provided for reference purposes only. Apple solved this problem with the release of Mac OS X Snow Leopard 10.6, this article only applies to older versions of the operating system.

If you are an iPhone user who charges your phone using your Mac when you are at home or at work it can get tiresome having iPhoto launch every time you connect your phone. It would seem like there would be an obvious way to stop iPhoto opening each time you connect and there is but its not in the place where you change other iPhone settings — iTunes nor is it in iPhoto itself but you will find it in the sometimes forgotten Image Capture application.

The Image Capture application is not all that advanced in its functionality, you can select an application to open when an image capture device such as a camera or iPhone is connected or none at all. Doing nothing and having to open iPhoto all by myself whenever I connect a camera is not too much of a hardship but there is a way to get the best of both worlds and the solution is to create our own very simple application that detects if we have just connected our phone or another camera and then do what we want it to do, open iPhoto if it is my camera I have connected or do nothing if I just want to charge my iPhone.

You can download the Application already created and skip down to Using the Application automatically or if you prefer to know what the code is doing create the application yourself very simply.

Download Application ZIP File (3,000 bytes)

Creating our own Application

We will create an application that checks the name of the last USB connected device, if it is an iPhone then we do nothing if it is another device we open iPhoto. Open Applications > AppleScript > Script Editor and type or copy & paste:

on get_device_name()
  set list_devices to "ioreg -Src IOUSBDevice | grep ‘^\\+’"
  set get_name_of_last to "tail -n 1 | sed ‘s/^\\+-o \\(.*\\)@.*/\\1/’"
  set command to list_devices & " | " & get_name_of_last
  return (do shell script command)
end get_device_name

on run
  if get_device_name() is not equal to "iPhone" then
      tell application "iPhoto" to activate
  end if
end run

Now from the menu bar File > Save As… and make sure you set the format to Application, the default is Script. Save it to the Applications folder or any other location on your Mac.

Using the Application automatically

Image Capture Preferences window

You will end up with your new application selected as the default application to open when a camera is connected to your Mac.

We now have an application that will detect if we have connected our iPhone or any other image capture device. We now will set the computer to run our new application when a device is connected. The default device is not set in iTunes or iPhoto but a dedicated application called Image Capture. Open Applications > Image Capture and open the preferences pane from the menu. Click other and select the script you have just created. The script will then run each time you connect an image capture device, if its your iPhone it will do nothing, otherwise it will open iPhoto as normal.

Note: If you have Aperture installed and prefer to use it rather than iPhoto simply replace the line in the script that opens iPhoto with application "Aperture" to activate and there you go.

Addendum 28/08/09: With the release of Snow Leopard (10.6) Apple has resolved the issue with an update to the Image Capture utility that allows you to set preferences for individual devices. So although you will have no need for this script in Snow Leopard it is worth noting that it will not run without the now optional Rosetta installed. Also Apple have moved the AppleScript applications from it’s own folder to only giving you the AppleScript Editor now located in the utilities folder.

This article was posted on 21 August 2009 in Apple, Code, iPhone

That's the end of this article. I hope you found it useful. If you're enjoyed this article why don't you have a look around the archives, where you can find some more tutorials, tips and general ramblings.