Monday, March 27, 2006

GNOME and the dbus daemon

It is a fact that dbus is becoming popular and that many parts of GNOME are starting to use it. Nowadays, some applications even fail to start if dbus is not present (e.g. epiphany).

Unfortunately, things do not work out of the box when installing GNOME from sources — or when using an "uncustomized" OS; see below — because there is nothing in GNOME that launches a dbus-daemon session at startup. Therefore, the user is forced to either:
  • Change his ~/.xinitrc to do exec dbus-launch gnome-session instead of the traditional exec gnome-session.
  • Edit his gdm configuration files to launch dbus-daemon before gnome-session.
As you can see, both "solutions" are cumbersome because they break the previous behavior and because they require the user to take extra steps to get things working.

Of course, in the disordered Linux world, distributions such as Ubuntu or Fedora Core include customized and rather complex X startup scripts that launch dbus-daemon during a session setup. Non-dbus-enabled systems (such as NetBSD) could ship modified gdm packages to avoid this problem, but users could still hit a problem when using the traditional startx or other session managers such as xdm or kdm.

I do not need to mention that some systems (e.g. NetBSD again) will not ever include — unless things change dramatically — a call to dbus-daemon in their standard X11 scripts.

A possible solution is to modify the gnome-session utility to spawn a dbus-daemon process on its own, just as it does with gconf or gnome-keyring. This way the user needn't remember to start dbus on his own as the GNOME session manager will do it automatically. With this in place, GNOME magically works again in these dbus-agnostic systems.

And yes, this solution is already implemented. It has kept me busy for two days but you can find the code in bug 336327. I hope to get some positive feedback and integrate it into pkgsrc until an official gnome-session release does it (if ever). If it is not integrated... well, I guess I'll have to go the gdm-patching route.

By the way, I have to say this: more than 300 lines of C code to do something that can be achieved in less than 10 lines of shell script... people seem to like to make their lives more complex than need be ;-)

5 comments:

  1. And what if I am not a fedora user nor a gnome user, but yet I wish to run a program that wants to make use of dbus?

    Why cannot the dbus developers provide a way for applications which use it to launch it on demand? Maybe you should read up on how KDE solves this problem, which does not suffer from these problems.

    ReplyDelete
  2. I meet the problem, google give me this site, i apply your tips and all works fine with my gnome on netbsd.

    Thanks a lot !!

    zat

    ReplyDelete
  3. YES IT WORKS!!!
    I also was solving this issue with gnome on NetBSD 4.99 (beta), with packages for 4 release. Unfortunately, the pkgsrc guys have done little to faciliate our situations, therefore, many thanks to you for this easy and well-working way.
    exec dbus-launch gnome-session
    did the job!
    thanx a lot many times
    Kolaloka

    ReplyDelete
  4. dbus-* is using up over half of one of my two CPUs. What the heck is it doing that it needs so much CPU time? I have one shell up running 'top' in Ubuntu 9.04.
    I smell needless complexity.

    ReplyDelete
  5. I have got the same problem as dan in Ubuntu 9.04. Has anyone got a solution?

    ReplyDelete