3

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?

detly
  • 29,332
  • 18
  • 93
  • 152

2 Answers2

0

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:

enter image description here

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

Giacomo Tesio
  • 7,144
  • 3
  • 31
  • 48
  • If I'm using the wrong service name, why would it work under Unity? And wouldn't I get a DBUS error? Also, the `UBUNTU_MENUPROXY` is set as required. – detly Apr 10 '13 at 00:39
  • I don't think so. No error. In a bus I expect to being able to subscribe a service that has not been exposed yet, but will be exposed later. The bus works like a mediator. That's (one of) the differences between a bus and a client-server architecture. – Giacomo Tesio Apr 10 '13 at 06:46
  • BTW, check you have indicator-appmenu installed since it install such service. – Giacomo Tesio Apr 10 '13 at 08:23
  • 1
    Even though GNOME doesn't automatically use such a service, what I'm trying to figure out is: how does Unity do it? Can GNOME copy its behaviour by running a couple of commands, or is it much more complicated than that? That's what this question is about. – detly Apr 10 '13 at 10:27
  • Oh, the `indicator-appmenu` is indeed installed. – detly Apr 10 '13 at 10:27
0

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?

user226447
  • 55
  • 3