Scripting your desktop with dogtail

Today I was preparing some slides for my upcoming talks at 7th Encuentro Linux 2006 in Chile. I had planned to use some music in sync with some slides. However embbeding music in OpenOffice Impress is not easy. Also I’d prefer to use a PDF with evince in presentation mode. Solution? Using evince for display slides and totem for playing the music, both syncronized using a dogtail script. Here are the fundamentals:
Guess what page evince is displaying from:

If the page has changed, check in an array if the new slide has music. If no music associated, press pause button on totem. If music associated, search totem playlist for the song and press play button. That’s all: 30 lines of python where you can embbed your music array:


import gtk
from dogtail.tree import root

music = {}
music['3'] = '03. Nina Simone - Pirate Jenny'
music['5'] = '04-raimon - diguem no.mp3'

current = '0'

def check_music():
        global music, page, play, totem, current

        if current == page.text:
                return True
                current = page.text

        if music.has_key(page.text):
                entry = totem.child(roleName='table cell', name=music[page.text])
                if == 'gtk-media-play':
                if == 'gtk-media-pause':

        return True

evince = root.application('evince')
toolbar = evince.child(roleName='tool bar')
page = toolbar.child(roleName='text')

totem = root.application('totem')
play = totem.child(name='gtk-media-play')

tag = gtk.timeout_add (500, check_music)


Next improvement would be adding a gui for creating playlists, associating PDF presentation and slides, lauching evince and launching totem with the created playlist

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>