Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Launch iPhoto only on camera, not iPhone, connect iOS devices
I have been continually annoyed with the way that iPhoto would start whenever I plugged my iPhone into my computer. The only pictures I take with my iPhone are to help me find my space in a parking lot, or so I can reassemble something I am taking apart. I do not want to archive these pictures. However, I do still want to use iPhoto to take the pictures off my digital camera. My previous solution was to set Image Capture to disable launching iPhoto in every case of camera attachment, and then manually launching iPhoto when necessary.

Luckily, Sam Stephenson at 37signals provided me with a solution that will launch iPhoto when a camera is attached, but not when my iPhone is attached. Sam realized that within the preference pane of Image Capture, an arbitrary application can be set to launch whenever a camera is connected. This solution utilizes the shell command ioreg combined with grep to search through the USB devices connected to the computer.

The script is able to sort through the connected devices and see if a specific device is connected. If that device is connected, iPhoto will be launched. Since the application is set to run whenever a camera is connected, it provides a method of sorting between the iPhone and a digital camera. Sam does a really great job of explaining every step for those not proficient with the terminal or scripts.

While this is quite useful as is, I wanted a slightly more generic form. I wanted to launch iPhoto for every camera that was connected, but never for my iPhone. Instead of searching the I/O Kit registry for a specific camera, I decided to search for any entry containing the word Camera.

My first plan was to just edit Sam's script such that it would look for the word Camera and when found, launch iPhoto. That code looks like this:
--initialize variable to a known value
set cameraName to "0"

-- perform script to see if there is any attached USB
-- device that has the word "Camera" in its name
try
  set cameraName to 
   (do shell script "ioreg -Src IOUSBDevice | grep 'Camera'")
end try

-- if there is a camera attached, start iPhoto
if length of cameraName is greater than 6 then
  activate application "iPhoto"
end if
Upon realization that grep throws an error if it cannot find what it is searching for, I decided to attempt a minimalist script. Below is a version that is slightly less intelligible by utilizing try to perform the logic.
try
  do shell script "ioreg -Src IOUSBDevice | grep 'Camera'"
  activate application "iPhoto"
end try
This works because if grep throws an error (i.e. the word Camera wasn't found), then the try routine is terminated before the activate... line is reached.

After copying/pasting either of these scripts into Script Editor and saving as an application, one can go to the Preferences in Image Capture and set this application to open when a camera is connected. This can be done by clicking on Other in the drop down menu, then selecting the application that was just created. Image Capture is located in the Applications folder.

I was even able to snag a snazzy icon from within the iPhoto 6 bundle to make my script look a little more professional. By control-clicking on iPhoto.app, choosing Show Package Contents and navigating to Contents » Resources, I found an image I like called import_camera.tiff. This can be set as the icon for the application by first opening import_camera.tiff in Preview and copying it to the clipboard (Command-C). Next, click on the application and bringing up the Get Info window by pressing Command-I. The process is completed by selecting the generic script icon in the upper left (with a click) and pasting the clipboard contents (Command-V) over the top.

This works well for me, but you might find Sam's specific method much more useful -- it depends on your situation. Both methods have issues when the camera and iPhone are connected at the same time.

[robg adds: This worked as described (both versions) in my testing.]
    •    
  • Currently 2.30 / 5
  You rated: 3 / 5 (10 votes cast)
 
[29,448 views]  

Launch iPhoto only on camera, not iPhone, connect | 9 comments | Create New Account
Click here to return to the 'Launch iPhoto only on camera, not iPhone, connect' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Launch iPhoto only on camera, not iPhone, connect
Authored by: benzado on Mar 10, '08 10:12:39AM
As I already noted in a comment on the 37signals blog, I wrote a variant of the script that works for any camera and does not have issues if you connect an iPhone when a camera is already connected, or vice versa.

http://benzado.livejournal.com/240117.html

[ Reply to This | # ]
Launch iPhoto only on camera, not iPhone, connect
Authored by: leamanc on Mar 10, '08 08:30:18PM

Thanks, this is just what I was looking for! I plug my iPhone into my work laptop occasionally when I'm low on power. It's always annoyed me to have to quit iPhoto every time.

In fact, I had just got done quitting iPhoto today when I noticed this hint come up on my iGoogle page's OS X Hints widget. Perfect timing!



[ Reply to This | # ]
Launch iPhoto only on camera, not iPhone, connect
Authored by: bcometa on Mar 19, '08 09:44:29AM
"try
do shell script "ioreg -Src IOUSBDevice | grep 'Camera'"
activate application "iPhoto"
end try"

brilliant hint Sam & darick! exactly what I needed and works seamlessly in the background so you really never have to know it's there. fyi to anyone considering this... you can still just open iphoto with iphone attached to download iphone photos.
thanks!!
-brian
corewerkz

[ Reply to This | # ]
Launch iPhoto only on camera, not iPhone, connect
Authored by: lokon1979 on Apr 16, '08 11:41:09PM

in fact, if you don't have any photos in your iPhone's camera roll (that is, those you took with your iPhone), iPhoto won't auto launch.

so if every time iPhoto auto launch with your iPhone plug in, just import all the photos into iPhoto and empty the iPhone's camera roll. you can put those photos into an album in iPhoto (even better make a smart album), and sync them back with iTunes. iPhoto won't auto launch with synced photo albums, but only if you have any photos in iPhone camera roll.



[ Reply to This | # ]
Launch iPhoto only on camera, not iPhone, connect
Authored by: quella on Apr 17, '08 11:21:58AM

I'm wondering id this can be done with a NOT <> iPhone to launch iPhoto. My wife and I often do not plug in the camera direcly, we take the card out and place it in our card reader hooked up to the iMac's USB. When I followed the above script, iPhoto only auto launched for the camera and not the flash. It would be nice to saw that iPhoto should launch when NOT an iPhone not when there is a camera. I will need to do some work on this. Great place to start from. Thanks for sharing.

Quella



[ Reply to This | # ]
Launch iPhoto only on camera, not iPhone, connect
Authored by: PeterDie on Aug 02, '08 02:26:42PM

With two brands of camera's, I have the same problem. I don't use a cardreader, but a NOT option would be nice. But you can work around this by piling it up, one rule after another, with the name of your cardreader as GREP option for you.

My script looks like this:

try
do shell script "ioreg -Src IOUSBDevice | grep 'NIKON'"
activate application "iPhoto"
end try
try
do shell script "ioreg -Src IOUSBDevice | grep 'Kodak'"
activate application "iPhoto"
end try
--- And just to be on the save side or guest camera's
try
do shell script "ioreg -Src IOUSBDevice | grep 'Camera'"
activate application "iPhoto"
end try




[ Reply to This | # ]
Launch iPhoto only on camera, not iPhone, connect
Authored by: PeterDie on Aug 02, '08 02:50:24PM

Oh, and by the way, this script also is a nice way to start up the right app, pro and amateur:

try
do shell script "ioreg -Src IOUSBDevice | grep 'NIKON'"
activate application "Aperture"
end try
try
do shell script "ioreg -Src IOUSBDevice | grep 'Kodak'"
activate application "iPhoto"
end try



[ Reply to This | # ]
Launch iPhoto only on camera, not iPhone, connect
Authored by: toddself on Sep 01, '09 05:14:54AM

So. I just upgraded to Snow Leopard, but since this script was originally compiled with Leopard's AppleScript editor it was actually a PowerPC app. Since Rosetta is no longer installed it kept prompting me to install Rosetta, but eh, I'd rather not.

So I went and recompiled it and then opened Image Capture in Snow Leopard. But woah.

Image Capture now lets you set a specific action PER DEVICE. You no longer need to do anything like this. Totally revamped. Awesome.



[ Reply to This | # ]
This Isn't Working with iTunes 10 and iPhoto 8
Authored by: SGS65 on Sep 05, '10 05:34:32PM

I loaded the following script as an app:

try
do shell script "ioreg -Src IOUSBDevice | grep 'Camera'"
activate application "iPhoto"
end try

It looks like it wants to work and even does when i plug in my iPad and/or iPhone; neither of those launch iPhoto....PERFECT!!

The problem comes in when I plug in my camera. It launches iPhoto (so far so good) but then it asks me the following question:

"Do you want to use iPhoto when you connect your digital camera?"

My only options are "Decide Later", "No" and "Yes".

If I select "Yes" then it automatically updates "Image Capture" preferences with IPhoto thereby setting everything back to normal and not using the above script.

What should I do?



[ Reply to This | # ]