dbus无法通过python找到compiz服务
好吧,你知道,我很少使用 dbus 或 perl,所以我可能会说一些不太对劲的事情。
我正在尝试使用 dbus 以编程方式与 compiz 配合使用。看看 compiz wiki http://wiki.compiz.org/Plugins/Dbus,我明白了python 似乎是最简单的方法。所以我得到了这个
import sys, dbus, subprocess
bus = dbus.SystemBus()
bus.get_object('org.freedesktop.compiz','/org/freedesktop/compiz')
,但是这给我带来了问题,因为显然 dbus 找不到 compiz dbus 服务。语法是正确的,它适用于 org.freedesktop.EverythingElse
dbus.exceptions.DBusException:org.freedesktop.DBus.Error.ServiceUnknown:任何 .service 文件均未提供名称 org.freedesktop.compiz
奇怪的是,我用 Google 搜索并设法获得了列出服务的 perl 脚本(使用 org.freedesktop.DBus),它显示 compiz 是其中之一。
另外,perl 似乎能够使用 compiz 服务。但是,我不认为我可以用 Perl 编写它,因为我不太擅长 Perl,而且我什至不知道 dbus 是如何工作的,所以我会在那里自杀。
我试图能够用 compiz 做一些事情,比如更改工作空间。我想我可以用伪造的按键来做到这一点,但这太过分了,我可能想添加更高级的行为。
这是 arch-linux 的新安装,所以我想知道是否缺少某个软件包。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
D-Bus 有多个独立的总线 - 一个始终可用并由系统守护程序和服务使用的单个“系统”总线,以及任意数量的“会话”总线1,一个对于每个正在运行的 X11 会话,您自己的程序将连接到该会话。
Compiz 连接到会话总线,因为它是一个用户程序(不是系统守护进程并且缺乏权限)并且可以在多个会话中运行(如果所有实例都连接到同一系统总线,则只有第一个可以声称巴士名称)。
您可以使用 D-Feet 浏览连接到该网络的所有程序系统和会话总线。
1 未来注意事项:有多种建议引入“用户”总线,以便在同一用户的所有会话之间共享,并摆脱“会话”总线,但这还没有发生然而。
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).
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.