My #nowplaying poster for Clementine stopped working with the upgrade to Ubuntu 17.04 Zesty. After short debugging with D-feet it turned out that there were some changes to the way it interacts with DBus – which is, I guess, also the reason why it can be controlled properly through the Media menu now.

However, I was (am) totally ignorant re: DBus, so figuring out how this pretty complex system worked, in one hour, still slightly tipsy, past 2am, was not exactly a simple task. Though it was still faster and easier than getting vsftpd to work properly (sober and early afternoon), as there I just gave up and apt-get purged it.

From what I can comprehend, the Clementine implementation for DBus now only accepts MPRIS2, instead of both that and MPRIS1 (what I used before).

First, I had to change the get_object line to this: return bus.get_object('org.mpris.MediaPlayer2.clementine', '/org/mpris/MediaPlayer2')

Next, I had to replace the GetMetadata method, which was now missing, with a direct Get of the Metadata property. So it turned into data = clem.Get('org.mpris.MediaPlayer2.Player', 'Metadata', dbus_interface='org.freedesktop.DBus.Properties')

But it was not over yet. Not only did the whole structure of the DBus objects change (or at least it seems so to a layman like me), some of the keys to metadata are now prefixed with “xesam” too, so the “artist”, “album” and “title” keys are now “xesam:artist”, “xesam:album” and “xesam:title” respectively. Luckily D-feet let me look at the data directly so I could just copy the keys.

Also, “xesam:artist” is now an array, so unless you want to concatenate multiple artists (if present), you’ll have to use data['xesam:artist'][0]. For reference, I use ', '.join(data["xesam:artist"]).