Controlling vagalume client using python

I've recently been playing with the docky python bindings, and started by writing a helper to interact with Vagalume, a lightweight client (I later added it to a project on launchpad). The vagalume DBus methods and signals are mostly undocumented, but they can be found lurking around after a quick look at some of the source code.

import dbus
import gobject
from dbus.mainloop.glib import DBusGMainLoop

class Vagalume(object):
    def __init__(self):
        self.bus = dbus.SessionBus()

        self.player = self.bus.get_object('com.igalia.vagalume',


    def song_changed(self, *args):
        state = args[0]
        if state == 'stopped':
            #do something when the player is stopped
        elif state == 'playing':
            artist = args [1]
            title = args [2]
            album = args [3]
            #do something with the data here...
            self.playing(artist, title, album)

    def stopped(self):
        '''Run when music is stopped'''

    def playing(self, artist, title, album):
        '''Run when new song is played'''

if __name__ == "__main__":
    app = Vagalume()

    # gtk mainloop can be used if you're using this as part of a gtk app
    mainloop = gobject.MainLoop(is_running=True)

You'll probably notice the method song_changed. This is a method which is registered with DBus and run each time the 'notify' signal is emitted from vagalume. This checks whether the notification is due to vagalume starting a new song or stopping the current one and runs either self.stopped or self.playing. These two methods by default do nothing, so subclassing Vagalume to make them do something useful is good:

class MyFancyVagalume(Vagalume):
    def stopped(self):
        print 'just stopped the beat'

    def playing(self, artist, title, album):
        print 'now playing "%s" by %s' % (title, artist)

To interact with vagalume do something like:

vagalume = Vagalume()

# do anything you want with dbus

take a look at the source ( for all of the functions available

LaTeX in your system tray

Whilst procrastinating on writing GCSE physics coursework, I thought it would be neat to have LaTeX run in the background and notify you when the document you're working on contains errors.

I wrote a python application which puts a small icon in the system tray. You can configure it to compile a LaTeX document.

It has a couple of settings for things like input file, output directory and automatic PDF opening (useful with evince, since opening refreshes the file if it is currently open in an existing evince window). It supports simple error messages for both LaTeX and BibTeX.

It uses GTK for the system tray icon, and libnotify to display the error message notifications.

The project is on launchpad here:

There's a small site on sourceforge:

© Louis Taylor. Index ¦ Archives ¦ Pelican ¦ Theme.