Using Linux with iPhone the easy way.

Update Oct. 27, 2019: Installed Pop! OS and it is a solid OS. Still using Shotwell and Samba. Works vey well and photos download faster now.

Update: I installed Ubuntu Budgie 19.04 and use Shotwell. Shotwell on this OS works perfectly for importing. When the file manager mounts the iPhone unmount from the dropdown in ‘Places’ – folder icon – on the top bar then open Shotwell and select iPhone and you should have no issues.

Step one: Photos and video.

Most distros will mount the DCIM so you can access your photos, but I want to control them from the phone and select from there what I want to keep. So I setup a sync folder on my largest drive and setup Shotwell to watch its photos folder on the same drive. I then setup MEGA Sync, which is like Dropbox but you get 50gb free, to save to the sync folder. I wrote a small Python program to move files from the sync folder to the photos folder and set it as a task to run every 10 minutes. I turned off the camera sync in the MEGA iPhone app, otherwise it will move every photo you take. When I want photos in Shotwell I simply move the photo(s) to the MEGA app on the phone and let the cron task and Shotwell manage the files as they show up. It works great.

The code is simple, here’s an example:

#!/usr/bin/env python
import os
import shutil
 
def move_files(src_root, dest_root):

    dest_photo = os.path.join(dest_root,'Photo')
    dest_music = os.path.join(dest_root,'Music')
    dest_other = os.path.join(dest_root,'Documents')

    for root, dirs, files in os.walk(src_root):
        for _file in files:

            file_path = os.path.join(src_root, _file)

            if os.path.isfile(file_path):

                ext = os.path.splitext(_file.lower())[-1]

                if ext in ['.mov','.jpg','.png','.mp4']:
                    dest = os.path.join(dest_photo,_file)
                    shutil.copyfile(file_path,dest)
                    os.remove(file_path)
                elif ext in ['.mp3','.ogg','.flac']:
                    dest = os.path.join(dest_music,_file)
                    shutil.copyfile(file_path,dest)
                    os.remove(file_path)
                else:
                    dest = os.path.join(dest_other,_file)
                    shutil.copyfile(file_path,dest)
                    os.remove(file_path)
                    
if __name__ == "__main__":
    
    base_src = '/mnt/storage/MEGASync/'
    base_dest = '/mnt/storage'
    
    move_files(base_src, base_dest)

You could modify this script to isolate and move any file type to various folders, like if a Python file gets dropped into the Mega folder you could have the script move it to Code, or move text files to Writing. This Python code should also work on OS X and Windows. Make sure you change the paths to yours.

Add a directory named outgoing to the Megasync directory for anthing you want to pick up on the phone so it doesnt get moved. Anything there will be left alone since we are not traversing all sub directories.

Step two: Music.

Since you cannot manipulate the contents of the iTunes library on the phone I dumped Apple’s music player. I hated the ads anyway, plus I do not stream. I could install iTunes in Wine but I like Rhythmbox. I installed Flacbox on the iPhone and setup a Samba share on my music folder on my laptop. I logged into the share in Flacbox where I manage the music and playlists on my phone. I don’t mind managing phone and desktop playlists separately. Eitherway, my whole library on my machine is on the iPhone at my deposal without storing it there, unless I want to. I also researved my ip on my router so I never need to remount the share unless I change things.

Step three: App data

Install ifuse if it’s not installed.

sudo apt install ifuse

Create a folder in mnt named iPhone.

You will need the app id. Here is an example of an app named Number9 by a company named Magic Hat and how to mount its sandboxed folder:

sudo ifuse /mnt/iPhone –appid com.magichat.Number9

If successful you can browse the app’s files. This is what I am working on now. It’s a pain as I do not want to jailbreak my device and have to guess or connent to iTunes to get the ID. If there is a way on the phone I coundn’t find it.

If you need help with Samba I’m certain there are resources on the internet.

Other options?

Photos: Digikam will connect to the phone but it rarely worked for me. Alternatively Rapid Photo Downloader worked better but still hit or miss. It will also allow duplicates as will most photo managers.

Music: In Flacbox you can fire up its internal server and move music through a web browser. A little more work but it works. There are other players that will allow music imports, I think Vox will, but they are greedy.

Password Manager: If you keep Passwords in a manager you can use Keepass, but Enpass is the best. I have used it for years on Mac and now they have a Linux version that syncs with the iPhone version.

Note:

If you’re not keen to crontab in the terminal this tool makes life easy, and it works on Ubuntu 18.04. Gnome Scheduler