Mounting and Copying iPhone Photos via CLI on OS X

Lately, except for the very occasional iTunes full backup, I’ve just been intermittently copying photos from my iPhone via my Linux machines, mounting with Thunar and gvfs.

Recently, I had reason to do a bit of poking about, and it turns out that libimobiledevice, and more specifically, ifuse, is the way to go for scripting. ifuse will mount your iOS device as a virtual file system, and let you copy photos and other media via regular command-line tools like rsync (it can mount the root file system only if your phone is jailbroken). If you want to get this working on arch, it’s very straightforward. You can add a udev rule and basically script to your hearts content. (I’ll probably set up an rsync backup script sometime.)

ifuse also runs on OS X fine, and while installation is a bit more involved, it worked perfectly for me running El Capitan 10.11.5, MacPorts 2.3.4, and osxfuse 2.8.2.

Once it’s installed, you can just run ifuse [/pick/your/mount/folder] and you’re ready to go.

Performance isn’t spectacular, but is reasonable, rsync runs at about 10-15MB/s via USB 3.0 on a Core i7 Mac Mini.

Changing Volume in OS X in the Command Line

One of the things that seems to have disappeared recently (certainly doesn’t work in Lion) is half-increment volume changing. This is quite inconvenient when I’m using some more sensitive headphones.

That was the impetus for the latest addition to my bashrc, a helper function that lets you set volume in the command line (scale is 0-100):

vol () { osascript -e "set volume output volume $*"; }

How to Install Pida on OS X

For some reason, I got it into my head that I wanted to try out Pida (a Python IDE that embeds Vim or your editor of choice) on my Mac. Well, actually from the description, it sounds pretty cool, right? The screenshots are pretty neat too. Unfortunately, the end result on OS X is somewhat less than compelling.

However, it was a huge fight getting it setup, so I figured I’d write this down for posterity.

There is a PIDA MacPort, however there is no maintainer, it’s for Python 2.6 only, and it didn’t work out of the box for me. You’ll need to fight it enough that you might as well go whole hog. Here’s how I got Pida running w/ MacPorts python27.

First the ports:

sudo port install librsvg py27-gtk py27-gnome dbus-python27 py27-notify-python
sudo port install vte +python27
sudo port install vim +python27 +x11 +gtk2

Then the Python libraries:

sudo easy_install py
sudo easy_install pygtkhelpers
sudo easy_install Logbook
sudo easy_install bpython

Next, after grabbing the source, your build environment:

PKG_CONFIG_PATH="/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/pkgconfig" PATH="/opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin:$PATH" python setup.py build_ext --inplace
running build_ext

Now, you’ll be able to run, but you may get a dbus error (which won’t let you select your editor among other things). Here’s how I made sure that dbus was running:

launchctl list | grep dbus
sudo launchctl load -w /Library/LaunchAgents/org.freedesktop.dbus-system.plist
launchctl load -w /Library/LaunchAgents/org.freedesktop.dbus-session.plist
launchctl list | grep dbus

Note above that dbus-system should be as root, and dbus-session should be loaded as the user.

Once I did this I was able to get up and running, however the Python shell subprocess throws an exception for me, and the font rendering and overall look, and of course all the non-vim keyboard shortcuts are painfully alien. Sadly, if you’re looking for a vim-like IDE-ish solution on the Mac, I think Vico, while quite new and still incomplete, is probably a better bet. If you’re looking for better Python introspection/debugging with a not-totally-awkward keyboard shortcuts (and incidentally, dead easy OS X installs), Reinteract and iep look to be the best choices I’ve found. (There’s also Spyder, which has a python26 Macport, but it depends on qt4-mac which may cause your MacPorts to build the world.)