I run iTunes about once a month. Which means my iPhone doesn’t sync very often. I hate iTunes. But I like syncing!
So let’s do this: automatic hourly syncing without launching any graphical applications.
Macs have a little secret. iSync. iSync won’t sync with your iPhone, because it’s stupid, but it will get you there with some canoodling. Run iSync, go to preferences, and select ‘Show status in menu bar’, you will get a spinning arrow icon in your menu bar. The ‘Sync Now’ option from that menu will sync with your connected iPhone; just calendar and contact information (not music), but that’s all that matters anyway.
OK, so you have this icon that will manually sync without running iTunes. But that requires clicking on things. And fuck clicking on things. We can do it in cron. WE’LL DO IT LIVE!
How? Bring up your terminal. Run “Sync Now”, and quickly execute…
ps auxww grep -i sync
…in your terminal, before it finishes syncing. You probably see three *Sync applications running: AddressBookSync, AppleMobileSync, and iCalExternalSync. Copy-n-paste those three extremely long commands into a text file. Add a shebang and a /bin/bash and name it with a .sh. That’s a bash script, my friend.
Why don’t I just give you the script? Because the command line depends on the device ID of your phone. A long hex string. It’s unique to your phone, so you need to get it. Easiest way is through that ‘ps’ command above, though you could use the Xcode Organizer or Tiny Umbrella instead.
So once you have the command, your bash script will look something like this:
/System/Library/Frameworks/AddressBook.framework/Resources/AddressBookSync.app/Contents/MacOS/AddressBookSync –oneshot –sync com.apple.AddressBook –entitynames com.apple.contacts.CalendarURI,com.apple.contacts.Contact,com.apple.contacts.Date,com.apple.contacts.Email Address,com.apple.contacts.Group,com.apple.contacts.IM,com.apple.contacts.ImageTransformationInfo,com.apple.contacts.Phone Number,com.apple.contacts.Related Name,com.apple.contacts.SmartGroup,com.apple.contacts.Street Address,com.apple.contacts.URL
/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/Current/AppleMobileSync.app/Contents/MacOS/AppleMobileSync –oneshot –sync com.apple.MobileSync. <YOUR IPHONE IDENTIFIER> –entitynames com.apple.calendars.Attendee,com.apple.calendars.AudioAlarm,com.apple.calendars.Calendar,com.apple.calendars.CalendarOrder,com.apple.calendars.DisplayAlarm,com.apple.calendars.Event,com.apple.calendars.Organizer,com.apple.calendars.Recurrence,com.apple.contacts.Contact,com.apple.contacts.Date,com.apple.contacts.Email Address,com.apple.contacts.Group,com.apple.contacts.IM,com.apple.contacts.Phone Number,com.apple.contacts.Related Name,com.apple.contacts.Street Address,com.apple.contacts.URL
/System/Library/Frameworks/CalendarStore.framework/Resources/iCalExternalSync –sync com.apple.iCal –entitynames com.apple.calendars.Attendee,com.apple.calendars.AudioAlarm,com.apple.calendars.CalDAVAccount,com.apple.calendars.Calendar,com.apple.calendars.CalendarOrder,com.apple.calendars.DisplayAlarm,com.apple.calendars.Event,com.apple.calendars.MailAlarm,com.apple.calendars.Organizer,com.apple.calendars.Recurrence,com.apple.calendars.Task,com.apple.ical.calendars.DotMacPublisher,com.apple.ical.calendars.Node,com.apple.ical.calendars.ProcAlarm,com.apple.ical.calendars.RootNode,com.apple.ical.calendars.TaskOrder,com.apple.ical.calendars.URLPublisher
And then you just call that from cron. Name it something like… iphone_sync.sh. Edit your crontab:
And add a job to run once an hour:
0 * * * * /Users/trevor/Documents/Scripts/shell/iphone_sync.sh
Bingo! Silent, automatic, hourly, two-way synchronization between your Mac and your iPhone.
Oh yeah, you can vanish that iSync icon from your menu bar now.
[mine is an iphone 3gs. mine is an os x 10.6.6. mine is an ios 4.2.1. mine is jailbroken. your might not work.]