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

The AWN bus name is com.google.code.Awn and /com/google/code/Awn is the object path. In the following descriptions, TaskName refers to the title of the task (i.e., the text in the AwnTitle tooltip shown above a task), and xid refers to the hexadecimal ID that X assigns to a "window". Both of these attributes can be found by running xwininfo in a terminal and clicking on a window - the window ID followed by the task name are on the line xwininfo: Window id:.

[edit] Change Task Icons

These calls are used to set a task's icon by using its name and the location of a image file.

SetTaskIconByName (string TaskName, string ImageFileLocation)
UnsetTaskIconByName (string TaskName)

You can also use an application's Xid instead of its task name

SetTaskIconByXid (long xid, string ImageFileLocation)
UnsetTaskIconByName (long xid)

[edit] Information Bubble

AWN allows you to print some text on top of an task's icon.

awn.SetInfoByName (string TaskName, string SomeText)
awn.UnsetInfoByName (string TaskName)

or

awn.SetInfoByXid (long xid, string SomeText)
awn.UnsetInfoByXid (long xid)

[edit] Progress Information

There is also a Progress pie chart that can be used to set some type of timer.Note that I have not used this call so I am not exactly sure how it works.

awn.SetProgressByName (string TaskName, int SomePercent)

or

awn.SetProgressByXid (long xid, int SomePercent)

There is no 'Unset' method, you can do that by setting the value to 100

[edit] Menu Items

These items appear when a user right-clicks the task. The first two methods return the ID of the menu item.

awn.AddTaskMenuItemByName (string TaskName, string stock_id, string item_name)
awn.AddTaskCheckItemByName (string TaskName, string item_name, boolean active)
awn.SetTaskCheckItemByName (string TaskName, int id, boolean active)

These are the signals that are emitted when the menu items are activated.

MenuItemClicked (int id)
CheckItemClicked (int id, boolean active)

[edit] Samples

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