As recently mentioned I was looking for useful hacks for the iPod Notes feature, and as Google didn't turn up much of interest I started writing one myself. The obvious first application: an offline feed reader.
Turns out it's remarkably easy to do this. The Notes file format is basically text with some HTML markup, and even allows for links between individual documents. I.e., converting a feed into a series of notes and an index is pretty straightforward.
The harder part is the syncing mechanism. My requirements were: syncing has to work on a default OS X installation, it should be able to sync with my 2nd gen nano, and it shouldn't touch any other removable drives or iPods when you plug them in. launchd makes it easy to get notified when any new drive gets plugged in. But how do you make sure it's the right one?
Uniquely Identifying Removable Drives
It took me a while to figure out a way to uniquely identify the iPod -- there are a number of options with varying trade-offs. In the end I decided on a method that should work for many other removable drives, not just iPods. Took a while to get there though...
The most obvious identifier, the drive name, never seemed like a good option. Drive names aren't unique, and they can change. I don't want to reconfigure my sync software just because I decided to rename my iPod.
Next option: older iPod models had a hidden file /iPod_Control/Device/SysInfo that contained an iPod serial number, but since late 2006 that's no longer the case. Instead the iPod serial is now stored inside a hidden plist that you can request with a SCSI INQUIRY command -- which involves too much code for my taste, and seems a little brittle. People put a lot of work into reverse-engineering iPod internals, but it's still a game of cat and mouse.
Another option is to determine the pod's hard drive model and serial number, but I haven't found a way to do this with only standard OS X tools. smartctl -i can do it, but smartmontools aren't shipped with OS X. I'm suspecting there is a device file with that information somewhere, but couldn't find one. Add a comment when you know more.
Instead I ultimately decided on using Volume UUIDs -- they're sufficiently unique, they identify a specific partition, and they seem work for all kinds of removable drives (unfortunately not for my old MP3 player and memory stick.)
So if you combine this identifier with launchd (to get informed of volume changes) and rsync (to do the copying) and some Ruby glue you have a pretty decent syncing mechanism. And it's not even iPod-specific -- you could also use it to do auto-backups when you plug in a specific drive, and do other fun stuff with removable devices.
Current State
At the moment this application isn't much more than a collection of Ruby scripts and a launchd plist, not very user-friendly. I'm toying with the thought of creating a simple UI to configure sync options, and a basic plugin mechanism to allow to sync more than just feeds, but haven't yet come up with a method of creating an appealing interface that doesn't involve a lot of work... maybe you have some ideas. I basically want to be able to do it in an afternoon and be done with it. (Although I've written some Objective C and Cocoa code I'm not much of an expert.)
There also is no public SVN for this yet, but I'll create one when I'm sufficiently happy with the state of this.
I'm now testing this offline aggregator on the road -- seems like an excellent way to read news bits during my daily bus routine. (But it's actually not that easy to find sources that still work when you lose links & images...)
Comments
That is awesome!
Julian Stahnke, 2007-05-27 23:58 CET (+0100) Link
Ace. My nano display is kind of tiny though. Pretty useful with the bigger models probably...
anil, 2007-05-28 00:01 CET (+0100) Link
I'm trying to move non-"purchased" songs from iPods to authorized iTunes installations on other machines. Such as when you take your iPod to work and want to transfer the tunes to that machine.
I can do this no prob. But of course I don't want to click and drag or go through the drag of opening terminal to do it every time.
Basically, one part of my quest is to find a reliable way to identify a volume as an iPod. I don't care what kind of iPod, I just want to know that it is one.
I got a hint sent to me about the IOKit but it's pretty hairy low-level C stuff that is not fun to dig through.
this is the hint i've recieved:
IOServiceMatching("com_apple_driver_iPodNub")
IOServiceMatching("com_apple_driver_iPodSBCNub")
I've also been digging in Apple's Developer docs, and in the part:
Accessing Hardware From Applications: Finding Devices in the IO Registry
I found something of this, and opened the dev tools app IORegistryExplorer
I've found the PID (product id, listed as idProduct in some IO registry plist xml file) and VID (vendor id, listed as idVendor)
Trouble is I haven't the faintest idea at the moment, how to access the IO registry to check this stuff, or what other iPods will have as PID.
If any of that helps you, let me know and help back...
cheers.
Goodbye Helicopter, 2007-12-02 03:24 CET (+0100) Link
Comments are closed. You can contact me instead.