简体   繁体   中英

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. 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. For example, the following Python script will show some results when run from the terminal when logged in under 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:

$ ./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).

It looks like these services are involved, since they are running constantly under Unity but not 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

$ /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

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

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:

在此输入图像描述

Thus I confirm that you should look for another DBus service (with a different API) specific for Gnome.

I assume there is no activity in that project. However, many people really like the idea of a hud for gnome! Is the script you posted here all the work that went into this or do you have some files left over which are better?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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