Blog

Hotplug Your iPod Touch With udev Rules

An updated version of these rules are available here. They have been modified to work with the ipod-convenience package provided for Ubuntuy 7.10 (Gutsy) users.

I've been fiddling around with syncing my iPod Touch in Linux over the past couple of days. Because support is not complete yet, the only way to effectively do this is over WiFi, which is actually a pretty cool solution. Even so, I wanted to make an attempt to mount the iPod's media share over WiFi automatically on connection to the USB plug so that when I set it down to charge it I would be able to, most of the time, sync with it too. Plus, since I've been using Gnome, mounting devices to /media/ causes a nice little icon to popup on the desktop, which seemed cool.

Basically, making the device hot-pluggable all boils down to creating a new rule for udev in /etc/udev/rules.d/. I was following the standard tutorial on udev rules, here. So, if you're following on from the instructions given for mounting your iPod Touch's media share over wifi, this udev rule will automagically create an entry for your ipod in /dev/ipod and try to mount the Media folder using SSHFS to /media/ipod/:

SUBSYSTEM=="usb", ATTR{idProduct}=="1291", ATTR{idVendor}=="05ac", ACTION=="add", NAME="ipod", RUN+="/bin/su greg -c '/usr/bin/sshfs -o workaround=rename root@192.168.1.70:/var/root/Media /media/ipod'"
SUBSYSTEM=="usb", ACTION=="remove", RUN+="/bin/su greg -c '/bin/fusermount -u /media/ipod'"

Obviously this rule applies to me and there is some customisation required. Replacing "greg" with your username and the IP address of the iPod (192.168.1.70, in my case) with the correct one is a must or these won't work. To use this rule, I just created a new file called "10-local.rules" in /etc/udev/rules.d/. I've also added a lovely little iPod touch PNG icon so that when the share is mounted, Gnome will display the iPod touch on my desktop.

And there you have it: hot-plugging your iPod under Linux. As an extension to this project, I'm looking into using HAL's rules instead to provide a frendlier device name, but I'm not sure how well this will work. The place to look for this is: /etc/hal/fdi/policy/, but more on that later.

Link to this article | Make a Comment
Tags: iPod Touch, iPhone, Linux, Ubuntu

Make a Comment