Copied from Reddit because r/linux is still down. Reddit post: http://webcache.googleusercontent.com/search?q=cache:https://www.reddit.com/r/linux/comments/13nwha5/how_to_import_ringtones_from_linux_to_iphone_ios/
Required Software: libimobiledevice, ifuse, libplist, ffmpeg
Caveats: The ringtone will play from beginning to end without any time limit and will NOT loop. This is probably fixable but I don't know how. A restart is required to use new ringtone.
This guide describes how to covert a sound file and import it as a ringtone for iOS devices.
- Cut your sound file to the desired length. You can use any software for this.
- Convert your sound file to AAC and change its extension.
ffmpeg -i soundfile.extension soundfile.m4a
mv soundfile.m4a soundfile.m4r
- Connect your iOS device and pair it if necessary. This is usually done via a prompt on your iOS device.
- Mount your iOS device.
mkdir ~/ios
ifuse ~/ios
- Copy your ringtone to your iOS device.
cp soundfile.m4r ~/ios/iTunes_Control/Ringtones/
- Backup ~/ios/iTunes_Control/iTunes/Ringtones.plist and then convert it to plain text. If you don't have the file for some reason, there is an example in step 7.
cp ~/ios/iTunes_Control/iTunes/Ringtones.plist Ringtones.plist.bak
plistutil -i ~/ios/iTunes_Control/iTunes/Ringtones.plist -o Ringtones-text.plist
- Add your new ringtone to the plist file. This structure should be followed beneath 2 <dict> entries:
<key>soundfile.m4r</key>
<dict>
<key>Name</key>
<string>"Song Name Here"</string>
<key>GUID</key>
<string>"16 digit string, set to anything"</string>
<key>Total Time</key>
<integer>"Has no effect afaik"</integer>
<key>PID</key>
<integer>"A random long number"</integer>
<key>Protected Content</key>
<false/>
</dict>
Here is an example with 3 manually added tracks:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ringtones</key>
<dict>
<key>RDGO.m4r</key>
<dict>
<key>Name</key>
<string>bodies</string>
<key>GUID</key>
<string>B9753FD82AE718E2</string>
<key>Total Time</key>
<integer>28756</integer>
<key>PID</key>
<integer>4918251813855823051</integer>
<key>Protected Content</key>
<false/>
</dict>
<key>RDGO2.m4r</key>
<dict>
<key>Name</key>
<string>Drowning Pool - Bodies (Full Song)</string>
<key>GUID</key>
<string>B9753FD82AE718E3</string>
<key>Total Time</key>
<integer>28756</integer>
<key>PID</key>
<integer>4918251813855823052</integer>
<key>Protected Content</key>
<false/>
</dict>
<key>letter.m4r</key>
<dict>
<key>Name</key>
<string>Letter</string>
<key>GUID</key>
<string>B9753FD82AE718E4</string>
<key>Total Time</key>
<integer>2000</integer>
<key>PID</key>
<integer>4918251813855823053</integer>
<key>Protected Content</key>
<false/>
</dict>
</dict>
</dict>
</plist>
- Save file and convert it back to binary. This will overwrite the file in your iOS device.
plistutil -i Ringtones-text.plist -o ~/ios/iTunes_Control/iTunes/Ringtones.plist -f binary
At this point, you feel victorious. You have edited an iOS system file and copied your ringtone. It appears in your library and plays beautifully. You excitedly ask someone to call you and... The default ringtone plays. Because there is one last step.
- Reboot your iOS device. Hope this helps, please reply back if it works or doesn't work for you.