Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Is it possible to add to or edit the Session Indicator menu items?

Is there an easy way to do this, or would it involve recompiling a custom build?

I cannot find much relating to this online.

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

some refs:
- jimi312 / Titlebar Menu / source — Bitbucket:
- Programming with DBus using PyQt
- Unity/QA/StateIntrospection - Ubuntu Wiki: especially example code

At the moment passive querying can extract information such as shown in this post:
How does one find out which application is associated with an indicator icon? .

Bookmark: How can I add items to the indicator-session menu?

I am also exploring the answer to this question as it relates to DBus, to use as high a level interface as possible to avoid low level programming. The ultimate objective is to create an HAPIIIII (Host Application Panel Indicator Integrated Interface Icon Installer - Happy! ay yi yi yi yi!) that minimally identifies the host applications of the indicators and the sub-aps. of their component menues. Maximally it would allow modifications to the menues such as the session-indicator menu including the top level menu, ie. the icon indicator of the unity-panel itself.

It would be good to know which, (if any!) modifier methods exist in the DBus environment to modify the DBus, so the indicator panel and it's components, such as Session Indicator, could be modified as you require.

The following commands reveal the interface methods to manipulate the session indicator bus information but unfortunately the parameters used in these methods are not described here - the reference above supplies links to the documents describing the general indicator interfacing - but specifics for the session indicator are still needed.

The output from

qdbus --session  com.canonical.indicator.session

implicates the existence of menu interfaces as the items below:

/
/org
/org/ayatana
/org/ayatana/indicator
/org/ayatana/indicator/service
/com
/com/canonical
/com/canonical/indicator
/com/canonical/indicator/users
/com/canonical/indicator/users/menu
/com/canonical/indicator/session
/com/canonical/indicator/session/service
/com/canonical/indicator/session/menu

The interfaces can be examined with:

gdbus introspect --session --dest com.canonical.indicator.session \
                 --object-path /com/canonical/indicator/users/menu --recurse

and

gdbus introspect --session --dest com.canonical.indicator.session \
                 --object-path /com/canonical/indicator/session/menu --recurse

Note the internal reference to interface com.canonical.dbusmenu.

For a real comprehensive dump use:

gdbus introspect --session --dest com.canonical.indicator.session --object-path / --recurse

Several sub-aps are bound to the session indicator drop down menu but what is not clear is whether these interface methods just transfer data to the associated sub-menu aps or whether in fact there is a communication channel to the session indicator ap itself so its menu can be "methodized".

Also,

qdbus --literal --session  com.canonical.AppMenu.Registrar           \
                          /com/canonical/AppMenu/Registrar           \
                           com.canonical.AppMenu.Registrar.GetMenus  \
| sed -e 's/], \[/],\n[/g' | sort -k 4 -V

provides a list of interface menu associations (there are menusfor the windows and also for the indicators like the session indicator, which is which in the list below still needs determination)

[Argument: (uso) 25167301, ":1.22", [ObjectPath: /com/canonical/menu/18005C5]],
[Argument: (uso) 25165828, ":1.22", [ObjectPath: /com/canonical/menu/1800004]],
[Argument: (uso) 48234500, ":1.81", [ObjectPath: /com/canonical/menu/2E00004]],
[Argument: (uso) 55244411, ":1.114", [ObjectPath: /com/canonical/menu/34AF67B]],
[Argument: (uso) 55370996, ":1.114", [ObjectPath: /com/canonical/menu/34CE4F4]],
         ...
[Argument: (uso) 65083174, ":1.275", [ObjectPath: /com/canonical/menu/3E11726]],
[Argument: (uso) 65085474, ":1.275", [ObjectPath: /com/canonical/menu/3E12022]],

Examining

qdbus --session  com.canonical.AppMenu.Registrar /com/canonical/AppMenu/Registrar 

it may be these methods are useful:

method void org.freedesktop.DBus.Properties.Set(QString interface_name, QString property_name, QDBusVariant value
method void com.canonical.AppMenu.Registrar.RegisterWindow(uint windowId, QDBusObjectPath menuObjectPath)
method void com.canonical.AppMenu.Registrar.UnregisterWindow(uint windowId)

Note the parameter identified as menuObjectPath. These method names are qualified with {un}RegisterWindow, so the methods perhaps are irrelevant to indicator menues.

Once the correct methods with their parameters are identified it is easier to use qdbus (cannot use QVariant parameters however) or D-Feet than gdbus to invoke the methods.

Basically qdbus and gdbus are functionally the same and use identical parameters except:

  • qdbus does not identify the separate components with --dest, --object-path, --method, ... but instead requires the corresponding attributes be given in exact order
  • gdbus method calls handle more parameter types
  • qdbus is not as exhaustive asgdbus especially w/ --recurse
  • qdbus can expediently extract its command parameter sequence via double or triple click from its output w/ a middle click to concatenate it to the end of the command

The answer
How does one find out which application is associated with an indicator icon?
in the post mentioned above describes how to use qdbus expeditiously as an expedient technique to compose the scripts.

The manpage man gdbus (or gdbus:) has a better exposition than man qdbus but consider D-Feet.

share|improve this answer
add comment

Your Answer

 
discard

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.