Unused Cycles

April 29, 2009

Amarok 1.4 Sync with iPod Touch 2G in Linux

Filed under: GNU/Linux, iPod Touch — Kevin @ 11:22 am

Since I’ve gotten my iPod Touch 2G, I’ve been forced to use iTunes, which I never really liked. Not just because it’s proprietary, but I really never cared for the interface and how it handles playlists. While four months of iTunes usage has warmed me a bit to it, I like being able to choose what application I use, especially because running iTunes means I have to run Windows XP in a Virtualbox virtual machine. Furthermore, I prefer Amarok 1.4 on KDE’s functionality more than I do iTunes or any other music player. Thankfully, with the recent release of the 24kpwn exploit on the iPod Touch 2G which allows an untethered software jailbreak, it’s possible to use Amarok with the iPod Touch 2G!

First a bit of background. The iPod generally uses a file called “iTunesDB” to store locations and tags of all of the files on your iPod. If you put music on your iPod without it being entered into the database, the iPod software won’t recognize it and you won’t be able to play it. Over the years, people have developed support for writing the iTunesDB without iTunes; on Linux, this is specifically done using libgpod. This database was the same with every iPod, so it was easy to use a new iPod with existing music software. Even the iPod Touch 1G was compatible with libgpod (albeit in a roundabout way).

With the introduction of iPod Touch firmware 2.x, Apple decided to “obfuscate” the database so that it could no longer be reproduced. All of the software that could once sync with iPods (Amarok included) was rendered useless with iPod Touch firmware 2.x.

Thankfully, there’s a workaroud. The database obfuscation is controlled by an XML file found in /System/Library/Lockdown/Checkpoint.xml on the iPod Touch (and iPhone). As it is easy to edit that file with a jailbroken iPod Touch with OpenSSH installed, it’s a matter of changing


to use database version 2 instead. Version 2 of the database is — you guessed it — the unobfuscated version.

There’s one little problem. When you plug your iPod Touch into your computer and run fdisk -l, it doesn’t show up. The iPod Touch does not identify itself as a mountable drive, so you must do one of two things:

  1. Tunnel an SSH connection through USB using iTunnel (buggy, at least when I compiled from source on Arch Linux), 0r
  2. Mount your iPod Touch via Fuse over WiFi

The second method is great if you’ve got a wireless network to work from. If not, and your wireless card supports ad-hoc mode, you can set up a network just between your computer and iPod. On the other hand, if you do not have access to WiFi at all, your only option is the first, which I’ve found to be quite buggy on Arch Linux. Who knows, maybe you’ll have good luck, but I’ll continue writing this the assumption that you’re using the second method.

If you’re running a decent distribution, there should be a set of scripts called “ipod-convenience” in your repositories (it’s available in the apt repositories in Ubuntu, and Arch Linux has it available in AUR). It’s my suggestion to connect your iPod to your computer over USB as that will keep the WiFi connection from turning off when your iPod goes to sleep. After installing the scripts, edit /etc/defaults/ipod-convenience so that it holds the IP address of your iPod, then run ipod-touch-mount. It’ll ask for your password (twice) and try to mount your iPod’s filesystem at /media/ipod (make sure it exists and is writable by your user).

From there, just fire up Amarok 1.4 and set up your iPod like normal. File transfer rates depend on your card’s speed and the traffic around the local access point.

If you’re OCD like me, you like having lyrics on each of your tracks so that when you tap the music application it displays lyrics. Unfortunately Amarok does not handle this well (actually, at all).  To get it working requires recompiling Amarok. If you’re into that, then keep reading. If you’re not, then you can stop right here and either a) use gtkpod which handles lyrics and artwork (but I didn’t like how it handles audiobooks (I’m a huge Doctor Who fan and listen to Big Finish audios in my free time)), or b) forget about lyrics support.

Amarok just does not handle lyrics tags well at all. From what I can make out, it saves lyrics to its own database, not the USLT portion of the ID3v2 tag. Thus when you save the lyrics to a music file using an external program, Amarok doesn’t see it and vice-versa. You can install scripts that read and write to the ID3 tags, but even then lyrics don’t show up on your iPod.

What’s happening is that a song in a database has a lyrics flag that must be set. iTunes does this by looking at the file in question at transfer time, seeing if it has lyrics in its tag, and sets that bit in the database. Unfortunately, stock Amarok 1.4.10 does not have this capability. I’ve found a patch here for Amarok 1.4.4 that I applied manually to Amarok 1.4.10

That still didn’t quite work for me. It compiled fine, but something’s changed since Amarok 1.4.4 in the way that it checks the ID3v2 tags. The original function was looking for the lyrics themselves and returning the lyrics as a string. The way that the patch works, it doesn’t actually care what the lyrics are — it just wants to know if there are lyrics. After analyzing the changes made, I changed the method QString MetaBundle::lyrics() in metabundle.cpp to just do the following (excuse the sloppy tabbing, WordPress doesn’t handle HTML):

QString MetaBundle::lyrics() const
TagLib::FileRef fileref = TagLib::FileRef( QFile::encodeName( url().path() ), true );
if ( TagLib::MPEG::File *file = dynamic_cast<TagLib::MPEG::File *>( fileref.file() ) )
if ( file->ID3v2Tag() )
if ( !file->ID3v2Tag()->frameListMap()["USLT"].isEmpty());
return QString("there's something here...");
return QString("");

After recompiling and transferring a few songs, it worked! It’s not the most elegant solution, but at least you’ll get your lyrical goodness so that you can sing along to all those songs which you have no idea what they’re saying (Boom Shackalak, anyone?)

This patch only works for MP3 files, which brings me to my next (and final) point. As previously mentioned, I listen to audiobooks and I like the built-in audiobook format that iTunes uses (M4B) because it bookmarks your files. Amarok immediately recognized my M4B files as such and uploaded them to properly use the bookmarks. However, I also like to put the “cover blurb” on the lyrics tag so that when I start a new one I have a faint idea of what’s happening. Because the lyrics patch only works for MP3 files and not M4A (I tried getting it to work, but ran into an issue with Arch’s libmp4v2), you can’t have this capability. Thankfully, in looking over the iTunesDB code for Amarok, I found that if you set the genre to “audiobook” it’ll set the audiobook flag on the iPod — regardless of whether or not it’s an M4B file. What that means is that you can use regular old MP3 files as audiobooks (which gets me even further away from Apple’s proprietary junk!)

Hopefully this was a helpful post. It’s taken me a few days to get Amarok working to my tastes, but it finally is and I thought I’d share my research.

April 22, 2009

Using the Context Menu Key as a Compose Key

Filed under: GNU/Linux — Kevin @ 9:10 am

I’ve noticed over the last few months that I don’t use the “context menu” key very much. Actually, I never use it, and I find it really annoying when I’m scrolling through a webpage with my arrow keys and accidentally bump it. On top of that, I wanted an easy way to type letters with accents, so I could do things like type über or a ¢ sign without having to go to a character map.

If you’re new to Linux, what I was looking for is called a “compose key.” The compose key works like this: tap the compose key, then a modifier, and lastly the letter you want. For example, if I want an e with a grave accent, I type “compose, ` (the character next to 1), e” in that order, and voilà I get a nice è.

Now, how do you go about setting your context menu key to act as a compose key? In Linux, it’s as easy as typing

setxkbmap -option "compose:menu"

into a terminal. You’ll immediately have a compose key. Even things such as £ (compose, -, L) or € (compose, =, C) will work on a US keyboard now! A complete listing of compose key combinations is here. The only problem is, when you restart X, your settings will go away so you’ll have to run that every time you start X. You can do that one of two ways:

  1. In /etc/X11/xorg.conf, add Option "XkbOptions" "compose:menu" to your keyboard section.
  2. Add the previoius “setxkbmap” line to a startup script. For example, I’m running KDE 4.2, so I added that line to ~/.kde4/Autostart/startup.sh (chmodded so that it’s executable, of course) so that KDE will run that command every time I log in. In GNOME, it should be as easy as going to System>Preferences>Sessions.

I recommend using the second method, because it will only change the setting for your user. Who knows, perhaps other people do use the context menu key.

April 10, 2009

KDE 4.2 and Amarok 1.4 Multimedia Keys

Filed under: GNU/Linux — Tags: , , — Kevin @ 10:14 am

I just figured out something that has been plaguing me for about a week, so I figured I’d write a quick post about it.

I’d been using Amarok 2 lately because it’s integrated into KDE 4.2 fairly well. When I tried upgrading to 2.0.2, however, I had major issues with compilation, and then with databasing when it was finally compiled. That, coupled with the lack of an equalizer and other Amarok 1.4 features, convinced me to downgrade to Amarok 1.4 (which is in the Arch Linux repositories).

As previously mentioned, Amarok 2 had pretty good interfacing with KDE 4.2, including being able to use the KDE Control Menu’s Global Shortcuts. It was easy to set up my multimedia keys (play/pause, stop, next, previous) to work with Amarok 2. But after downgrading to 1.4 I lost that ability.

The solution is to open Amarok 1.4. Under settings, there is an option to configure global shortcuts. Just configure play/pause, etc., to your media keys and voila! It works great, even under KDE 4.2.

Blog at WordPress.com.