Awn now has a DBus backend! Which brings to life one of my main features for Awn, which was the ability for applications to control their Icons on Awn!
It is *very* new, and I haven't added all of my ideas, but Imy top 3 are now working:
Ability To Change Task Icon
This is especially important for media applications, so they can set the icon to whatever cover-art they have:
Yes, its FutureSex/LoveSounds, and that says alot for my music taste, but leaving that aside for the minute, you'll be happy to know that Mr. Timberlakes cover art is actually the Rhythmbox launcher :).
I basically have hacked the standard artdisplay plugin for Rhythmbox and added support for the cover to be shown on Awn. If there is no cover, it reverts back to the standard icon. I have included it in svn, under the new 'plugins' folder. Installation instructions are also included.
Little Information Bubbles
These would be important for applications such as Evolution, which could show how many unread emails you have:This is not a real-life plugin, its just a demo of what can be done. If I have time, I will make this into a proper plugin.
Progress Information
This is probably my favourite! In-built progress reports into the task icon:
*Update* An example video showing Firefox downloading a file:
This, again, is not a real plugin for Firefox, but demonstrates whats possible.
There is still a lot of work to do, regarding drawing, alignment, etc etc. However, now the basic boilerplate stuff is in, this should be easy to do.
Here are some things that I am going to add over the weekend:
- Ability to have a small icon composited on the main task icon. Think Epiphany settinging the current favicon onto its task icon.
- Ability to add menu items over dbus, and listen to their signals if clicked by the user. For instance, menu item for evolution to add a contact, Totem to pause a movie etc.
- Predefined 'types' of apps, with special buttons, i.e. a MEDIA_TYPE that shows buttons for reverse, play/pause, and forward.
- Some more styles to display the progress 'bar'.
- Option to attach a larger pixbuf to the 'tile' which shows on hover. So, Rhythmbox can attach a 400x400px sized album art, which would show with the window title.
If you want to write a plugin for your favourite app, heres some info that you'll need, the code is in Python, but should be easy to adopt for other languages.
bus = dbus.SessionBus()
obj = bus.get_object("com.google.code.Awn", "/com/google/code/Awn")
awn = dbus.Interface(obj, "com.google.code.Awn")
Gets you the basic awn object.
There are two main ways to get at your task,
- By the name of the application (string). This works best for single-instance applications.
- By the xid (long), which is best for multi-instance apps , as it will only effect the icon for that window. One way to get the xid is by calling GDK_WINDOW_XID(window->window).
- I am adding support for using the pid to reference your application.
To set the icon for a task, you need to call either SetTaskIconByName or SetTaskIconByXid. In python, it would be :
awn.SetTaskIconByName ("rhythmbox", "/tmp/rhythmbox-album-art.png")
or
awn.SetTaskIconByXid (long(xid), "/tmp/rhythmbox-album-art.png")
Yes, the second argument has to be a /local/path/to/the/image/file. Using /tmp is the best idea, as it will get wiped when you restart.
You have to call awn.SetTaskIconByName/Xid every time you want to update, even you are using the same file name (recommended as to avoid unneccessary junk in /tmp).
If you need to unset the icon, use :
awn.UnsetTaskIconByName ("rhythmbox")
or
awn.UnsetTaskIconByXid (xid)
The name may not always match, I am working on this, so be patient if your fav app does not work :).
Setting Information
Setting information is easy:
awn.SetInfoByName ("evolution", "23")
or
awn.SetInfoByXid (xid, "23")
Unset using:
awn.UnsetInfoByName ("evolution")
or
awn.UnsetInfoByXid (xid)
Setting Progress
This is very easy:
awn.SetProgressByName ("firefox", 60)
or
awn.SetProgressByXid (xid, 60)
There is no 'unset' function, just set the progress to 100 to clear the icon of the progress meter.
If you need any help, or need better API, just drop me a line. Also, we have a forum, thanks to Mike Jones (searayman), so if you do make anything based on the DBus backend, post it there so we can all have a look! I'll probably include some plugins with the main tarball, so let me know if you make something.
*Update* The forum seems to be down at the moment, so I recommend using the wiki to upload your creations. Just add a page under the 'DBus Plugins' page, you can also attach files to the pages you create. I have added the Rhythmbox plugin as an example.
*Update 2* Just to annoy me, the forum is actually back up again. So its up to you where you want to post your plugins, forum or wiki, whichever suits you best.
And Finally
I am going to do mass amounts of bug fixing over the next few days, and therefore expect svn to be in a bit of a flux as I sort some things out.