Using Linux with iPhone the easy way.

Copy Lollipop Playlists with Python.

Update Oct. 27, 2019: Installed Pop! OS 19.10 and it is a solid OS. I’m still using Shotwell, which is downloading photos perfectly without any need for a third party tool or code and I am also still using Samba to download and play my music in FlacBox.

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.

Update Feb. 2022: I moved to Manjaro awhile ago and I use KDE. I have been running KDEConnect on my iPhone for a few months now and it works great. KDEConnect can be used on Windows, OS X, and Android also. As time moved on I found that all the problems working with the iPhone has become mostly no problem. I still use the products listed below. Flacbox is awesome. SimpleNotes is awesome. Enpass is awesome. I have no issues moving images to my machine using Digikam. I don’t bother with iFuse and haven’t for a long time. I also don’t use Gnome Scheduler, as KDE has a task scheduler you can install that is supported and easily found in the software repos. With Dropbox and KDEConnect as the icing on the cake I am pretty much set. You do not need KDE to run KDEConnect. Check it out: https://kdeconnect.kde.org/download.html 

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. Either way, my whole library on my machine is on the iPhone at my disposal without storing it there, unless I want to. I also reserved 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 connect to iTunes to get the ID. If there is a way on the phone I couldn’t find it.

If you need help with Samba click here.

Other options?

Photos: Digikam will connect to the phone but it rarely worked for me. Alternatively Rapid Photo Down-loader 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.

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

Password Manager: Keeping passwords in a vault is important and certainly want to grab them from you desktop. You can use Keepass if you want to be strictly open source 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. I’m sure there are others.

Step Four: Notes!

Notes are important to me but I don’t need the complication of EverNote. If you want to take notes that sync to your Linux machine install Simplenote.