What Brave New World Is This?

16th November 2010

As most of you are probably aware, HAL is dead.  So let us all cry out: HAL is dead, long live… what, exactly?

If you’re wondering what on earth HAL is, it is (or was) a daemon that sat on your computer and told interested parties (such as KDE applications, via Solid) about various bits of the hardware.  This went beyond abstracting away kernel interfaces, however, and included information about laptop batteries that have been recalled, for example.

However, it was decided that HAL was getting too big for its boots and was failing to acheive its stated goal of “making hardware just work”.  But it was filling a need.  So what is sweeping into the void to replace it?

Well, there’s UPower, for all your power management needs.  It replaces those parts of HAL that dealt with screen brightness, the power button, the lid closing and entering various power-saving modes.  It even goes further than HAL ever did, allowing applications to request latency targets, for example.

Then there’s UDisks.  You may be thoroughly unsurprised to learn that it deals with the various bits of storage you may at various times attach to your computer: anything that appears as a block device, basically.

For many other services, you are expected to deal with either higher-level services like NetworkManager (or WICD, or other solutions) or with lower-level ones like PulseAudio or ALSA.  And for everything else, there’s direct interaction with udev, via libudev.

This is all very well, but what about all that extra information that HAL provided?  Well, UDev provides a device database that allows extra information to be stored with devices.  UPower provides battery recall information using this mechanism, for example.  There is a media-player-info project that provides UDev rules and some desktop files that furnishes interested applications with information about supported protocols and media formats of various portable media players.

But after that, I get stuck.  I guess that many of the video power management quirks that HAL documented are expected to be dealt with by the kernel.  But this is just an educated guess.

The major problem with this “kill off HAL” project is the sheer lack of documentation.  UPower has a useful website.  UDisks has an almost entirely unhelpful one.  media-player-info doesn’t even have a website, and you wouldn’t really know to go looking for one anyway unless you follow the right development mailing lists.

Solid is currently having problems with developing replacement backends for HAL.  What is the correct way to get the processor information that HAL previously exported?  LibMTP used to augment HAL’s media player information store with its own information, but there is no clear way for it to extend the information provided by media-player-info.  How should libMTP provide that information now?

All this should really be documented somewhere.  Maybe it is, and I just can’t find it, but that means it’s not documented in a sensible place.  The sensible places being the HAL website and the DeviceKit website (DeviceKit being the overarching term for the “stuff to replace HAL” – UPower and UDisks in particular).

I really hope someone knows what’s going on, and I wish they would communicate it to the rest of us.

EDIT: I realised that, freedesktop.org being largely composed of wikis, I could do some improvements myself.  The udisks site now has some useful information on it, and there is a media-player-info site.

The Magic of QtDBus, and the PropertyChanged signal

7th September 2010

I’ve had reason recently to delve into the inner workings of QtDBus.  It does more for programmers than I (and probably many of you) realised.

For example, when you tell qdbusxml2cpp to generate a proxy for you, it creates a subclass of QDBusAbstractInterface, and populates it with properties, signals and slots that correspond to the D-Bus properties, methods and slots.  But there’s more going on under the hood than it seems.  In particular, all those annotations for input and output types are used for more than just simple casting of QVariants.

Consider, for example, what happens when you fetch the value of a property of D-Bus type a{sv}.  This is a map from strings to variants.  The natural representation in Qt is a QVariantMap, but it could just as easily be in a QHash<QString, QVariant>, or even something based on std::map.  Qt doesn’t know.  So you can put an annotation in your D-Bus interface specifications, indicating what type it should be represented as:

<annotation name="com.trolltech.QtDBus.QtTypeName" value="QVariantMap"/>

OK, so what does qdbusxml2cpp do with this information?  Well, in this case, we’re annotating a property.  qdbusxml2cpp will produce the following code in the proxy class:

Q_PROPERTY(QVariantMap Foo READ foo)
inline QVariantMap foo() const
{ return qvariant_cast< QVariantMap >(property("Foo")); }

As you can see, it casts a property (which is a QVariant) to a QVariantMap.  But that surely demands that the QVariant already contains a QVariantMap and not, say, a QHash<QString,QVariant>?  Well, there’s some magic in QDBusAbstractInterface to deal with this for you.

Basically, when you request a property (QObject::property()), QDBusAbstractInterface requests it over D-Bus.  If it’s something simple, like a string (D-Bus type s), it gets demarshalled automagically in the internals of QtDBus, giving you a QString in this example.  But if it’s something more complex, like the above a{sv} type, QDBusAbstractInterface looks up the type information in Qt’s meta-object system, and uses that to demarshall it into the correct type – if the property type is QVariantMap, it will be demarshalled into a QVariantMap.

A similar trick is done for signals (note that if you get the signal signature wrong, you will simply never receive the signal).  Sidenote: if you add a QDBusMessage parameter as the last parameter of the slot you connect to a D-Bus signal, you’ll get a copy of the signal message.  You can even just have the QDBusMessage parameter, although you’ll be creating more work for yourself.

So, this is all very nice, but why am I telling you about stuff that “just works”?  Well, you have to watch out for the times when it doesn’t “just work”.  I’ll illustrate just such a case with an implementation of the PropertyChanged signal.

The PropertiesChanged signal is a recent addition to the org.freedesktop.DBus.Properties interface in the D-Bus specification that allows you to receive notifications when a property value changes.  It’s rather new and hasn’t even made it into the released version of the spec yet.  However, it will be supported by the next version of GIO.  Hopefully, it will be supported in a not-too-distant release of Qt (4.8?), but in the meantime you can quite easily add support yourself.

The signal looks like

org.freedesktop.DBus.Properties.PropertiesChanged (
    STRING interface_name,
    DICT<STRING,VARIANT> changed_properties,
    ARRAY<STRING> invalidated_properties);

where changed_properties is a dictionary containing the changed properties with the new values and invalidated_properties is an array of properties that changed but the value is not conveyed.

Now, on the server side, you can’t support it “properly”, because the introspection for the org.freedesktop.DBus.Properties interface is fixed by QtDBus, but you can emit the signal yourself anyway:

QDBusMessage signal = QDBusMessage::createSignal(
signal << "org.foo.MyInterface";

QVariantMap changedProps;
changedProps.insert("somestringprop", "newstringvalue");
changedProps.insert("someintprop", 4);
changedProps.insert("somemapprop", newmapvalue);
signal << changedProps;

QStringList invalidatedProps;
invalidatedProps << "invprop1" << "invprop2";
signal << invalidatedProps;


Easy as pie, right?  You can even have a helper method that does this:

void notifyPropertyChanged( const QString& interface,
                            const QString& propertyName )
    QDBusMessage signal = QDBusMessage::createSignal(
    signal << interface;
    QVariantMap changedProps;
    changedProps.insert(propertyName, property(propertyName));
    signal << changedProps;
    signal << QStringList();

On the client side, things are slightly more complex.  My approach is to insert a class into the proxy code heirachy.  While qdbusxml2cpp produces subclasses of QDBusAbstractInterface, I modify these to inherit a class of my own (DBusAbstractInterface) that in turn inherits QDBusAbstractInterface.  This class has all the magic needed to deal with the PropertiesChanged signal.

Essentially, it connects to the PropertiesChanged signal using QDBusConnection::connect(), and forwards this to any listeners.  So far, so simple.  But what happens if we have a property with D-Bus type a{si} (a map from strings to integers)?  Then the changed_properties map will contain an entry mapping the property name to an a{si} value.  How does QtDBus know how to demarshall this?

Well, the fact is, it doesn’t.  QtDBus will demarshall the changed_properties map into a QVariantMap (or whatever appropriate type the second argument of the slot has), but it can’t demarshall any complex types that are values in that map.  Do you want your a{si} map as a QMap or a QHash?  QtDBus doesn’t know, and so puts off the demarshalling by inserting a QDBusArgument value into the map.

If you know what structure you’re expecting here, you can just demarshall it with something like

QMap<QString,int> map;
changed_properties.value("foo").value<QDBusArgument>() >> map;

My helper class does something roughly similar to what QtDBus does internally, and uses the meta type system to figure out how it should demarshall the values in changed_properties.  But just remember that if you have a complex structure passed over D-Bus as a variant (D-Bus type v) and received in your code as a QVariant, the chances are it’ll be in the form of a QDBusArgument, and you’ll have to demarshall it yourself.

The Party of Gno

18th June 2010

I came across an interesting blog post about the FSF’s strategy on LWN, and thought it was worth sharing.

The essential argument is that the FSF does too much preaching about what people shouldn’t do, without offering constructive alternatives.

D-Bus threading issues

1st June 2010

There are some annoying issues and crashes in KDE 4 (and particularly in KRunner and Nepomuk) that are related to the thread-safety (or, rather, thread-non-safety) of libdbus-1.  kde-core-devel has seen some discussion about this recently.

There is a patch that fixes the issue, but it won’t make it into D-Bus before dbus-1.4, due to the fact that it changes the library behaviour and could potentially break bindings.  Thiago has confirmed that the change doesn’t break the Qt bindings, and (from the bug report), no-one has found any other bindings it breaks.

This is all just background on why, if you are running Arch Linux, you might want to check out the dbus-core-mt package on the AUR.  It’s dbus-core-1.2.24, as found in core, but with the afformentioned patch applied.  Note, however, that you use it at your own risk – it should improve KDE, but it may well break other stuff.

Exciting Nights at Akademy?

28th July 2009

I’ve come away from GCDS with several pieces of clothing I didn’t have before.  Some of them – a T-shirt I bought and three more given out by sponsors – were expected.  Others were not.  One of my roommates had to leave part way through the week, and (unsurprisingly, given that the room was as messy as you might expect from three guys) managed to leave a couple of items behind, which I picked up.  However one item still puzzles me.

I have a pair of jeans that are certainly not mine, and both my GCDS roommates deny owning.  Now, I’m pretty sure that our room didn’t see quite the level of excitement that leads to random people’s clothing being left around.  So the question is: where did they come from?


9th July 2009

Another day of the Gran Canaria Desktop Summit. After yesterday’s post, I got several offers of power adaptors. However, I ended up buying one on my way back to the hotel, along with a bunch of food for lunch today (the lunches here at the university are poor and quite expensive for what they are).

In fact, speaking of food, I had the worst meal I’ve had this week, and one of the worst I’ve had in my life, last night. We went to a Chinese all-you-can-eat buffet. Now, now, don’t scoff. I’m had some good (although never excellent) food at all-you-can-eat buffets. It seems that the Canary Islands is not the place for them, though. This one was so bad that after my first plateful, I was still hungry but didn’t want to eat any more. Avoid like the plague.

This was in direct contrast to the meal I had with the Amarok guys the night before, which was really nice (if expensive) – masses of paella, salad, chips and warm chocolate brownie. It was seriously good.

Today we had more Amarok discussions. So far we’ve discussed:

  • liblastfm on Windows
  • Playlist synchronisation
  • Unit testing
  • Whether scripts should be able to respond to Amarok quitting (and potentially slow it down)
  • A UPnP collection
  • Reorganising the source files
  • Playdar
  • The UI for dynamic playlists, and context-sensitive information for the area on the left of Amarok (where collections and services etc. are)
  • The EngineController class
  • Mac/Windows ports

Still to come:

  • Media devices update
  • The evil “organise files” bug (pro tip: don’t use Amarok 2 to organise your files for now)
  • UI clutter

We’ve had a very productive couple of days, and Leo’s been taking photos of the whiteboard, so we have a permanent record of our discussions.  Expect blog posts about the cooler things we discussed.


8th July 2009

It’s been a while since I posted. Such is life.

I’m really enjoying my first Akademy. I managed to forget a power adapter to convert between my British plug and the European sockets, but Nuno lent me one for a few days. I now have to find my own, though, as he went home today.

So, the conference. The keynotes on Saturday morning were really good. I recommend watching them when the videos are online (which they may be already). Of course, there is some furore over Richard Stallman’s talk, but I think that was always expected.

Yesterday was the KDE e.v. meeting, which I didn’t go to (not being a member of the e.v.). Instead, I slept in (sleep has been in short supply), went to the beach, and hacked. I put together a small plasmoid (87 lines of javascript) to show some controls for a media player. The idea is that you can put this on an auto-hiding panel on your desktop so that they don’t take up screen real estate, but are easily accessibly just by moving your mouse. The other half of the job, of course, is to do one that displays information. Then you can have the information about what song is currently playing permanently visible, and the controls only appear when you want them.

Today we had a very productive discussion on moving KDE to Git. The aim (if everything goes swimmingly) seems to be to move before KDE 4.4 goes into freeze. Amarok is intending to move very soon, though.

Speaking of Amarok, we’ve been sitting in one of the labs discussing things since the Git BoF. It’s amazing how much gets decided how quickly, especially when you’re used to deciding things on mailing lists. This is particularly true for user interface decisions. I’m expecting great things from the next release of Amarok.

Akademy rooms

25th May 2009

I figured I’d follow Peter Zhou’s lead and ask if anyone is still looking for a roommate at Akademy. I don’t bite, I promise…

What’s Playing, Doc?

17th May 2009

So, I was round at a friend’s, and he was playing with Amarok and the Plasma widgets screensaver, and wanted a way to see what was currently playing when his computer was locked.  Of course, I pointed him towards the Now Playing applet, but it was overkill for what he wanted – he didn’t want the buttons, or the sliders – just a display of the current information.  Well, I was in the mood for playing, and it took me about 15 minutes to construct a javascript plasmoid, most of which was spent researching how to use data engines from them.

The code I left him with was:

layout = new LinearLayout(plasmoid);

label = new Label();
label.text = 'No player'

plasmoid.dataUpdate = function(name, data) {
    label.text = 'Info:\n';
    for (var key in data) {
        label.text += key + ': ' + data[key] + '\n';

plasmoid.dataEngine("nowplaying").connectSource("org.mpris.amarok", plasmoid, 500);

This was in a file called “main.js” in a subfolder called “contents”. In the plasmoid folder (the folder containing the contents folder), I also put in a metadata.desktop file:

[Desktop Entry]
Name=Simple Now Playing
Comment=Now Playing as Matt likes it
X-KDE-PluginInfo-Author=Alex Merry
X-KDE-PluginInfo-Email=alex.merry [SPAMNO]@[SPAMNO] kdemail.org

Now it was just a case of calling plasmapkg -i . from within the plasmoid directory, and the simple widget was installed. This produces the following:


Of course, this will only work with Amarok, and doesn’t respond to Amarok being started or quit. That’s OK, it’s not much more work to deal with that:

layout = new LinearLayout(plasmoid);

label = new Label();
label.text = "No player found";

function firstSource() {
	var sources = plasmoid.dataEngine("nowplaying").sources;
	if (sources.length) {
		return sources[0];
	} else {
		label.text = "No player found";
		return '';

plasmoid.dataUpdate = function(name, data) {
	if (source == name) {
		label.text = 'Info:\n';
		for (var key in data) {
			label.text += key + ': ' + data[key] + '\n';	

source = firstSource();

npDataEngine = plasmoid.dataEngine("nowplaying");

npDataEngine.sourceRemoved.connect(function(name) {
	if (name == source) {
		source = firstSource();
		if (source) {
			npDataEngine.connect(source, plasmoid, 500);

npDataEngine.sourceAdded.connect(function(name) {
	if (!source) {
		source = name;
		npDataEngine.connect(source, plasmoid, 500);

if (source) {
	npDataEngine.connectSource(source, plasmoid, 500);

Of course, it’s not much work to only show the things you’re interested in, but this covers the interesting parts of the plasmoid.

Interesting note: it appears that if you replace the line label.text = 'Info:\n'; with label.text = '';, the subsequent calls to label.text += ... don’t work – you just end up with a blank label.

Why silence is better than 10 reasons

31st March 2009

This is a deconstruction of 10 reasons why GNOME is better than KDE, which is pretty obviously a piece of flame-bait. Wallen basically says as much at the start of the article. But I’m in the mood for dissecting arguments.

I would like to say right now that this is not a “10 reasons why KDE is better than GNOME” article. That would be inane. I have many GNOMEy friends, and no intention of trying to convert any of them. Anyway, I’m pretty sure that any one of you can come up with both 10 things KDE does better than GNOME and 10 things GNOME does better than KDE.

Instead, this is an excercise in deconstructing an argument. Critical thinking, if you will. Because Wallen completely failed to come up with 10 reasons for anything.

So, lets start at the top. “1. KDE 4″. I’m not really sure there’s anything to say about this, other than that the entire paragraph is simply a collection of unsupported statements (with no narrative to connect them). He doesn’t provide a single example to support any of his attacks (including ‘KDE was (and is) the first-ever “Microsofting” of the Linux desktop’ and KDE 4 was “painfully worthless”). OK, let’s move on.

“2. Start Menu”. Well, using Microsoft terminology when ‘”Microsofting” the Linux desktop’ was mentioned in the previous paragraph was probably intentional, but not helpful to any argument, really. We get “It should be pretty obvious” and “It should also be fairly obvious” almost straight off the bat. Chalk one down for unsupported statements.

There’s possibly a valid criticism about Kickoff and the lack of KDE 3′s quick menu applets being made in here, but it’s difficult to disentangle from the ad hominem attacks. And he probably has a point about discoverability of things like how to change the menu to “classic” style. Not that I believe such a thing is both possible and discoverable in any other desktop, so I’m not sure it really advances his original argument about one desktop being “better” than the other.

In “3: Nautilus vs. Dolphin”, he actually doesn’t compare Dolphin to Nautilus. He compares Dolphin to Konqueror, and the latter still functions as a file manager in KDE 4. OK, that first statement wasn’t entirely true. He says that Nautilus is Dolphin, but stable (and makes a reference to Dropbox that appears to bear no relation to anything else). That brings the number of potentially valid criticisms in this article up to about 3 (the arguments in section 2 were hazy).

He also says that users will find most of the features of Dolphin useless. And justifies this by mentioning one feature, possibly two if you count rating and tagging separately (Dolphin has more than three features, right?). One black mark next to “generalising from the specific”. And possibly “presenting exaggeration as fact”.

“4: Foundations”. I’m not sure why he picked this title. Qt 4 gets a passing mention (in the first sentence), and the only thing that is said about GTK+ is that there will be a version 3 soon. I guess you’re supposed to infer from context that this will break backwards compatibility. He also implies (but doesn’t say outright) that the port to Qt 4 was largely or solely because of the potential for a windows port. The reason was in fact because Qt 4 had a much-improved API, and Qt 3 was shortly to become unsupported by Trolltech (as was).

This section also has a fallacious comparison between GNOME 2.24, with it’s forward compatibility flags, and KDE 4 (a more sensible, although still not entirely accurate, comparison would be the as-yet-unreleased GNOME 2.30 with KDE 4). The thing is, he could probably have made a decent argument along the lines of GTK+3′s migration plan being better than QT 4′s, but he completely failed, largely by getting sidetracked with the Window port non-issue. Oh, and I’m really not sure what resources he believes are being diverted from the main project to work on the windows port. Or how KDE might go about forcing those people who insist on getting their favourite applications to run on Windows (as they did even back in KDE 3 days) to give up such an unworthy pursuit and return to the warm, fuzzy and – above all – morally superior fold of free unix-based operating systems.

Sorry, I seem to have had a nasty attack of sarcasm there. I’ll try not to let it happen again.

On the other hand, section four is possibly the most well-constructed section in terms of arguments. I had to remove the underpinning (the assumption that the move to Qt 4 was all about Windows) before the rest of the structure of the argument collapsed.

Oddly enough, in “5. Resources”, his one concession to KDE 4 (using fewer resources than KDE 3″ is highly disputed among those who measure such things in KDE. The rest of this section revolves around his decidedly unscientific comparison between the memory usage of KDE and GNOME (given the content of section 10, one has to assume that this means default installs of Fedora 10, but there is nothing to say so). He gets a difference of 10Mb when both desktops use more than 1.25Gb of RAM. That’s a 1% difference in memory usage. Apparently this means that “GNOME requires less hardware to run”. I’m not entirely sure where he intends to buy exactly 1.27Gb of RAM from (which, it seems, will run GNOME but not KDE – providing you don’t launch any other applications, of course). But, seriously, 1% is not a significant difference. Given that his measurement almost certainly includes kernel caches, and is probably based on the default installations of one particular distribution, it is almost certainly completely dwarfed by the error rate.

“6. Clutter”. Half-way there. Showing the desktop folder, it seems, is cluttering the desktop. Despite this being what just about every other desktop implementation out there does. *shrugs*. Let’s play along, then. This is a reasonable argument, but made at the expense of ignoring the facts. The major one is that it takes one click to remove the item he’s complaining about. So, a second argument that required me to actually respond with a fact, rather than dismantle purely on the basis of fallacious reasoning.

“7: Customization”. Again, lots of unsupported statements. GNOME is almost infinitely customizable (how?); KDE 4 locks you down (in what way?). Nowhere does he give even one example of something that GNOME allows you to customise that KDE doesn’t. He talks about mouse menus, but this appears to be a comparison of KDE 4 with KDE 3 (and I’m not sure what he means by “mouse menus”, either). And saying that you can’t change the look of something except by using the very mechanism that allows you to change its look (theming, in this case) is… true. But completely besides the point.

“8: System Tray overkill”. This is a comparison of the default setups on Fedora 10, not of the default setups of the desktop environments in general. So this is an example of generalising from the specific.

Apart from that, not all of the items he lists are actually part of the system tray (the clock, for example, is actually an applet, not a system tray icon). And desktop shells can’t do anything about the system tray other than display what programs offer. The applets, on the other hand, can be removed – both in GNOME and KDE. The one valid argument in this is about the loading time of the system tray. I think that’s 4 valid arguments (that couldn’t be immediately dismissed by stating a single fact) in total so far.

“9: Default applications”. Konqueror has been the default web browser of KDE (although not necessarily of any given distribution’s installation of KDE) since KDE 2, as far as I’m aware. So quite where he got the idea that Konqi has suddenly moved into this role, I don’t know. KOffice 2 hasn’t even been released, so I doubt it’s the default anywhere (although I’ve heard that Fedora can be pretty bleeding edge). And Firefox isn’t the default browser in GNOME, it’s Epiphany. Although that does use the same rendering engine as Firefox. And I’m not sure GNOME really has a “default” office suite. Basically, Wallen is confusing desktop environment defaults with distribution defaults. Repeat after me: Fedora is not representative of all Linux distributions.

So that’s a mix of generalising from the specific and ignoring certain facts.

“10: KDE = Vista?”. I can sum this up as “people don’t like Vista, and I think KDE looks like Vista, ergo KDE sucks”. Unfair? Well, maybe. But saying that you can make KDE look like Vista by installing the right theme (I assume Emerald refers to a theme) does not an argument make. And I know that Vista is famed for being unstable (slightly unfairly, I have to say), but all software goes through an unstable phase (except possibly TeX) and that doesn’t make it like Vista. Or unlike Linux (as in GNU/Linux, not the kernel). And he still hasn’t presented a convincing argument (or an argument at all, for that matter) for KDE 4 not being flexible. Plasma was designed to be much more flexible than kicker/kdesktop, and Wallen has failed to provide any evidence that it has failed in those aims. Not that I’ve presented any evidence it has succeeded in them, but my aim is not to prove the worthiness of KDE 4 but to dismantle Wallen’s arguments.

Finally, Wallen makes the common mistake of assuming that KDE 4 = Plasma. Well, OK, Dolphin got a mention. Yes, it’s probably the most user-visible component of a KDE 4 desktop session, but KDE is primarily a software platform, and includes a desktop shell as part of that. So that’s generalising from the specific again.

Well, I found four reasonable arguments in there, plus a few more that were recognisable as arguments even if they could be countered with a simple fact (I can forgive people for not knowing all the pertinent facts :-P). But most of the rest didn’t form any coherent argument at all.

I think that’s enough from me. I suggest you all go read about logical fallacies now, so you can give fancy names to Wallen’s arguments.

This has been a public service broadcast on how not to argue your case.

[Post edited slightly at 21:26 GMT 2009-03-31]


Get every new post delivered to your Inbox.