简体   繁体   English

如何从GNOME下的HUD DBus服务获得结果?

[英]How can I get results from the HUD DBus service under GNOME?

I'd like to (programatically) access results from Ubuntu's heads-up display (HUD) menu service under GNOME 3.6. 我想(以编程方式)访问GNOME 3.6下Ubuntu的抬头显示(HUD)菜单服务的结果。 I've been playing around with the DBus interface for the HUD with some success, but can't get it to work outside of Unity. 我一直在玩HUD的DBus接口取得了一些成功,但是无法让它在Unity之外工作。 For example, the following Python script will show some results when run from the terminal when logged in under Unity: 例如,以下Python脚本将在Unity下登录时从终端运行时显示一些结果:

#!/usr/bin/env python
import dbus

session_bus = dbus.SessionBus()
proxy_obj = session_bus.get_object('com.canonical.hud', '/com/canonical/hud')
hud_iface = dbus.Interface(proxy_obj, dbus_interface='com.canonical.hud')
query_result = hud_iface.StartQuery("ope", 5)

for res in query_result[1]:
    print res[0].encode('utf8')

hud_iface.CloseQuery(query_result[2])

Running it under Unity (in 12.10) I get: 在Unity下运行它(在12.10中)我得到:

$ ./hud.py
File &gt; <b>Open</b> Tab
File &gt; <b>Open</b> Terminal
dropbox &gt; <b>Open</b> Dropbox Folder
View &gt; Zoom <b>Out</b>
Terminal &gt; Set Character Encoding &gt; Add <b>or</b> Remove…

...but under GNOME 3.6 I don't get any results (no errors, nothing). ...但是在GNOME 3.6下我没有得到任何结果(没有错误,没有错误)。

It looks like these services are involved, since they are running constantly under Unity but not GNOME: 看起来这些服务都涉及到,因为它们在Unity下不断运行但不是GNOME:

/usr/lib/indicator-appmenu/hud-service
/usr/lib/x86_64-linux-gnu/indicator-application-service
/usr/lib/indicator-(whatever)/indicator-(whatever)-service

But if I start them up under GNOME, they exit soon after with 但是如果我在GNOME下启动它们,它们很快就会退出

$ /usr/lib/indicator-session/indicator-session-service

(process:4921): libindicator-WARNING **: No watchers, service timing out.

If I manage to run my script in that narrow window of time then I get results! 如果我设法在那个狭窄的时间窗口中运行我的脚本,那么我会得到结果! But how do I keep those services running? 但是如何保持这些服务的运行? And what starts them in the first place? 首先是什么启动它们? And do they include the application menu contents, or is that provided by another service? 它们是否包含应用程序菜单内容,还是由其他服务提供的内容?

Looks like you are using the wrong service name. 您似乎使用了错误的服务名称。 I've no GNOME 3.6 available right now, but you can list dbus services with 我现在没有GNOME 3.6可用,但您可以列出dbus服务

dbus-send --session --dest=org.freedesktop.DBus --type=method_call --print-reply /org/freedesktop/DBus org.freedesktop.DBus.ListNames

Moreover you should export UBUNTU_MENUPROXY=libappmenu.so before starting Gnome, or define it in /etc/environment 此外,您应该在启动Gnome之前export UBUNTU_MENUPROXY=libappmenu.so ,或者在/ etc / environment中定义它

Also check that you have installed the indicator-appmenu . 还要检查是否已安装指标 - 应用程序

However after reading here here , I guess that the GNOME desktop does not use such service: 阅读这里经过然而在这里 ,我想的是,GNOME桌面不使用这样的服务:

在此输入图像描述

Thus I confirm that you should look for another DBus service (with a different API) specific for Gnome. 因此,我确认您应该寻找另一个特定于Gnome的DBus服务(使用不同的API)。

I assume there is no activity in that project. 我假设该项目没有任何活动。 However, many people really like the idea of a hud for gnome! 然而,很多人真的喜欢为gnome hud的想法! Is the script you posted here all the work that went into this or do you have some files left over which are better? 您在此处发布的脚本是否包含了所有相关的工作,或者您是否有更好的文件?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM