indexwritingsjournal › 2012

grawity's journal

Why D-Bus is awesome

D-Bus is a relatively recent IPC system, replacing DCOP, Bonobo, and various hacked-together Unix socket protocols. It is still considered by some to be "bloat", but has quickly gained popularity nevertheless – mostly among GUI applications, though, but also in use by various system components; for example, both Upstart and systemd init systems are controlled over D-Bus.

One of the most useful applications of D-Bus is the MPRIS specification, which has no equivalents in other environments so far. Originally written by the VLC team, now part of Freedesktop.org, MPRIS is an interface specification for controlling media players over D-Bus. It defines the common "play", "pause", "seek" and other such commands, allowing any compatible player to be controlled with a single program – and there are many compatible players; one list counts as many as twenty, with MPRIS support being a common wishlist item for the others.

Screenshot – GNOME 3 Media Player Indicator
GNOME 3 "Media Player Indicator" extension

All of this means that instead of having twenty different commands to skip to the next song, or twenty different desktop applets, there only needs to be one (for example, the popular extension for GNOME 3 or my command-line utility), reducing the time needed to add support for the Awesome New Player of the Week.

IM clients are able to easily set the user's status to the currently playing song by any player implementing MPRIS, and even Ubuntu for their Sound Menu have switched to just being a MPRIS client in Natty, instead of Ubuntu's custom "Ayatana" protocol in earlier releases.

Unfortunately, not all players support MPRIS v2 yet – some only do the older and clunky v1, others are stuck with custom D-Bus interfaces or different IPC systems. (For example, mpd requires a bridge client that acts as a MPRIS service, although this is understandable for a player aiming to be network-transparent.) Buggy and/or incomplete implementations are also common; I spent some time recently fixing BeatBox and the Exaile plugin.

MPRIS itself is still somewhat minimal in an attempt to be easy-to-implement with any media player, so it still lacks such niceties as playlist management (although a play queue is supported) or changing of song ratings. For this, many apps still implement their custom D-Bus interfaces next to MPRIS.

These problems become relatively minor, however, once one realizes that there is no alternative at all – on Windows, only few such programs can be controlled using documented interfaces, while most of the time it is reduced to sending fake keypresses and button clicks with AutoHotKey, or even reading title-bars just to determine the current song, as I have noticed done by a Pidgin plugin to interface with foobar2000. Winamp was possibly one of the first to have good IPC support (based on Win32 messages) as part of its extensibility, but it might as well be the only one.

Screenshot – D-Feet introspection tool
D-Feet introspection tool

While remembering Winamp, something certainly could be written about the introspection feature of D-Bus – being just another interface with only a single method, it allows browsing supported D-Bus methods or properties in almost any D-Bus service. (The bindings for Perl and Python automatically implement the "Introspectable" interface, but even in C it is done almost always.) It is much easier to experiment with a system browsable in such tools as D-Feet than with one that requires reading a long list of numerical messages and their meanings (as with the Winamp WM_COMMANDS).

Gmane – how all mailing lists should work

Recently I discovered Gmane, a mailing-lists to NNTP gateway. It turned out to be the solution to several of the biggest annoyances I've had with mailing lists so far.

Gmane allows all mailing lists to be accessed using a standard protocol, NNTP, which provides a consistent interface instead of having to deal with five different web-based management and archive sites (Mailman, Pipermail, MHonArc, etc., etc.). I can tell my newsreader to kill uninteresting threads and highlight others, and even post replies to the "newsgroup".

Over NNTP, it's also easy to access archived messages, even those sent before subscribing to the list, in their original RFC*822 format instead of pipermail's heavily-filtered HTML archive. With my newsreader (Thunderbird), I can even make copies by dragging & dropping interesting messages to an IMAP folder, with their original headers and everything. Very few (in fact, close to none) web-based list archives offer "raw" or "mbox" versions.

The only downside is that Gmane mangles email addresses in the majority of lists, causing PGP signatures to be broken. But I suppose that's the cost of having publicly accessible a giant archive of email messages.


Previously

year 2011

year 2010

year 2009