Question

Ok, just so you know, I haven't worked with dbus or perl much, so I might say some things that are off.

I'm trying to use dbus to work with compiz programmatically. And looking at compiz wiki http://wiki.compiz.org/Plugins/Dbus, I see that python seems like the way that it is easiest to do this. So I got to this

import sys, dbus, subprocess
bus = dbus.SystemBus()
bus.get_object('org.freedesktop.compiz','/org/freedesktop/compiz')

This, however gives me problems because apparently dbus cannot find the compiz dbus service. The syntax is right, it works with org.freedesktop.EverythingElse

dbus.exceptions.DBusException: org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.compiz was not provided by any .service files

The weird thing is that I Googled around and managed to get a perl script that listed the services (using org.freedesktop.DBus), and it showed compiz as one of them.

Also, perl seemed to be able to use the compiz service. But, I don't think I could script it in perl because I'm not great at perl and I don't even really know how dbus works so I'd be killing myself there.

I'm trying to be able to do stuff with compiz like change workspaces. I guess I can do that with faked keystokes, but that's to much of a hack, and I might want to add more advanced behaviors.

It's a new install of arch-linux, so I'm wondering if I might be missing a package.

Était-ce utile?

La solution

D-Bus has several separate buses – a single "system" bus, always available and used by system daemons and services, and any number of "session" buses1, one for each X11 session running, to which your own programs connect.

Compiz connects to the session bus, since it is a user program (not a system daemon and lacking the privileges) and can be running in multiple sessions (if all instances connected to the same system bus, only the first one could claim the bus name).

bus = dbus.SessionBus()
bus.get_object('org.freedesktop.compiz','/org/freedesktop/compiz')

You can use D-Feet to browse all programs connected to the system and session buses.


1 Note for the future: There have been multiple suggestions to introduce a "user" bus to be shared between all sessions of the same user and get rid of "session" buses, but this hasn't happened yet.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top