Dbus Backend API

From AWN Wiki

Jump to: navigation, search

AWN has a dbus backend which can be used in applications(or their plugins) to control the way AWN displays that application's Icon and various other visual cues.

Contents

[edit] The API

[edit] DBus unique path: org.awnproject.Awn

Object paths:

  • /org/awnproject/Awn
 - Interface: org.awnproject.Awn.App
   * Methods:
     * GetPanels           ()                               -> (Array of [Object path] panels)
  • /org/awnproject/Awn/Panel[0-9]+
 - Interface: org.awnproject.Awn.Panel
   * Methods:
     * DeleteApplet        (String uid)
     * SetAppletFlags      (String uid, Int32 flags)
     * InhibitAutohide     (String app_name, String reason) -> (UInt32 cookie)
     * UninhibitAutohide   (UInt32 cookie)
     * GetInhibitors       ()                               -> (Array of [String] inhibitors)
     * DockletRequest      (Int32 min_size, 
                            Boolean shrink, Boolean expand) -> (Int64 window_id)
   * Properties:
     * Offset
     * Size
     * MaxSize
     * Position
     * PathType
     * OffsetModifier
   * Signals:
     * SizeChanged         (Int32 size)
     * OffsetChanged       (Int32 offset)
     * OrientChanged       (Int32 orient)
     * PropertyChanged     (String uid, String prop_name, Variant value)


[edit] DBus unique path: net.launchpad.DockManager

Object paths:

  • /net/launchpad/DockManager
 - Interface: net.launchpad.DockManager
   * Methods:
     * GetCapabilities       ()                         -> (Array of [String])
     * GetItems              ()                         -> (Array of [Object path])
     * GetItemsByName        (String name               -> (Array of [Object path])
     * GetItemsByDesktopFile (String desktop_file_name) -> (Array of [Object path])
     * GetItemsByPID         (Int32 pid)                -> (Array of [Object path])
     * GetItemByXid          (Int64 xid)                -> (Object path)
   * Signals:
     * ItemAdded             (Object path)
     * ItemRemoved           (Object path)
  • /net/launchpad/DockManager/Item[.+] (unspecified identifier)
 - Interface: net.launchpad.DockItem
   * Methods:
     * AddMenuItem       (Dict of {String key, Variant value} menu_hints) -> (Int32 id)
     * RemoveMenuItem    (Int32 id)
     * UpdateDockItem    (Dict of {String key, Variant value} hints)
   * Properties (implementing org.freedesktop.DBus.Properties)
     * string DesktopFile
     * string Uri
   * Signals:
     * MenuItemActivated (Int32 id)

Supported menu_hints:

Required:
- label + String
OR
- uri + String
Optional:
- icon-name + String
- icon-file + String
- container-title + String

Implementor can choose whether icon setting will be honored when the menu item is specified using the "uri" key.

Supported hints: All hints are optional.

- message + String
- tooltip + String
- badge + String
- progress + Int
- visible + Boolean
- icon-file + String
- attention + Boolean
- waiting + Boolean
[edit] Capabilities provisioned by Awn
- dock-item-badge
- dock-item-message
- dock-item-progress
- dock-item-icon-file
- menu-item-container-title
- menu-item-with-label
- menu-item-icon-name
- menu-item-icon-file
- x-awn-set-visibility

[edit] DBus unique path: com.google.code.Awn (deprecated)

Object paths:

  • /com/google/code/Awn
 - Interface: com.google.code.Awn
   * Methods:
     * SetTaskIconByName   (String name, String icon_path)
     * UnsetTaskIconByName (String name)
     * SetInfoByName       (String name, String message)
     * UnsetInfoByName     (String name)
     * SetProgressByName   (String name, Int progress)
     *    // XID variants
     * SetTaskIconByXid    (Int64 xid, String icon_path)
     * UnsetTaskIconByXid  (Int64 xid)
     * SetInfoByXid        (Int64 xid, String message)
     * UnsetInfoByXid      (Int64 xid)
     * SetProgressByXid    (Int64 xid, Int progress)

[edit] Samples

Warning: This section contains outdated code, the API used here is deprecated!

Note that you will need to import or reference the appropriate resources in your language. Like "dbus" in python and "NDesk.DBus" in C#/Mono

[edit] In python

bus = dbus.SessionBus()
obj = bus.get_object("com.google.code.Awn", "/com/google/code/Awn")
awn = dbus.Interface(obj, "com.google.code.Awn")

To call one of the methods you can do

awn.SetTaskIconByName("pidgin", "/path/to/icon.png")

[edit] In C# Mono

First define the interface

[Interface ("com.google.code.Awn")]
public interface AvantWindowNavigator
{
    void SetTaskIconByName (string app, string icon);
    void UnsetTaskIconByName (string app);
    void SetInfoByName (string app, string info);        
    void UnsetInfoByName (string app);  
}

To connect to the interface you can do

private AvantWindowNavigator awn;
awn = Bus.Session.GetObject<AvantWindowNavigator> ("com.google.code.Awn", new ObjectPath ("/com/google/code/Awn"));

Now lets call the SetTaskIconByName method

awn.SetTaskIconByName ("pidgin", "/path/to/icon")

[edit] External Links

Personal tools