Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm Unity Mail developer and I wonder if it's possible to add a shortcut to Messaging Menu from within the application (it's written in Python).

I need to connect it's user-display to a function in the application. For example, this is needed for "Mark all as read" command.

The specification only says about static shortcuts, which are added to .desktop file:

In the .desktop file itself, an application may specify shortcut actions that can be invoked regardless of whether the program is running. The syntax of these actions is defined in ApplicationShortcuts.

share|improve this question
up vote 3 down vote accepted

Yes, though the hand built bindings don't expose it, you'll have to use the GObject Introspected bindings to do it. Unfortunately, there isn't a tutorial that uses those yet.

To do this you'll need to get your IndicateServer and call set_menu on it. Which takes as a parameter the Dbusmenu that you'd like to provide. There are lots of ways to do that, but let me give you some quick pseudo code (as I'm not fluent in Python). Hopefully someone with edit privs that is can help.

menuserver = Dbusmenu.Server("/my/unique/path")
root = Dbusmenu.Menuitem()

first = Dbusmenu.Menuitem()
first.property_set("label", "First")
first.connect("item-activated", call_me_on_click)

second = Dbusmenu.Menuitem()
second.property_set("label", "Second")


There are other properties that can be set on menu items to do just about anything you want. You can also build them from GTK menus if that is more comfortable to you using the DbusmenuGtk.parse_menu_structure(). There is also API Documentation for DbusMenu.

share|improve this answer

You could always get the desktop file to run a script which you use to select the required action based on some saved file or other indication.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.