A “presenter view” for OpenOffice presentations on Linux

Earlier this week I was at @media Ajax, and it was great — more in an upcoming post. First, though, a quick bit of scripting I did. You see, it’s become apparent to me that I need a “presenter view” when I’m presenting; I have my laptop running dualscreen, so that the view I get on the laptop screen is not the view that appears on the projector. I need this, because I’m not Derek Featherstone; I can’t just see the slides and remember everything that I need to say. My slides are often just a single word, or a picture, and I can’t remember the thread of what I’m aiming at without notes.* So, I used to have notes on a bit of paper. The way I create presentations is:

  1. Write out, longhand, everything I intend to say, word-for-word, like it’s an essay or a playscript
  2. Go through my longhand script and identify all the slides I want to put in to bolster the points
  3. Spend some time with Flickr’s Creative Commons image search finding the images that I want for slides
  4. Put together a presentation
  5. Make notes for each slide expressing the bullet points of what I want to say, with notes to myself to remind me of any particular phrases I want to specifically remember
  6. Throw away the longhand script

The final step, after that lot, used to be “write out all of the notes in big writing on bits of A4 paper”. Then it occurred to me: why not use the presenter view to put my notes on? I used S5, Eric Meyer’s in-browser HTML/CSS/JavaScript based presentation system, for a long time to make my talks, and it has a presenter view. However, I got increasingly hacked off with it being slow and annoying, and so I resolved to use OpenOffice for presentations; it’s just easier. OpenOffice, though, doesn’t have a presenter view (there’s a spec for it, but it doesn’t yet exist). After a bit of casting about, I discovered that (a) OpenOffice will export presentations to PDF, and (b) Evince, the Gnome document viewer, has a presentation mode. So, thought I, I could use that instead. OpenOffice allows you to export the notes pages too into your PDF: if you’ve got three slides in your presentation*, each with notes, and you elect to include notes pages in the PDF export, then you get six pages in the resultant PDF — the first three are just the slides, and the second three are the slides at the top of the page with the notes below. So the idea appeared in my head: why not open the PDF twice, put PDF-1 on page 1 and display it on the projector, and PDF-2 on page 4 (the first notes page) and display it on my screen? Then just get them to advance in lockstep — when I advance the projector PDF by one page, it advances the notes view on my laptop screen by one page as well — and lo, I have a presenter view. Those of you with (a) modern versions of PowerPoint or (b) whatever the Mac presentation thing is called are doubtless laughing your heads off right now, and rightfully so. I can’t wait for the OpenOffice people to make this happen properly. Anyway, to do the advancing, you need a little script. This little script uses dogtail to provide the presenter view, and I used it on Monday and it worked perfectly. Be warned: this is not a proper solution. It’s a crappy hack, and if it de-bones your cat and deletes everything on your hard drive, don’t come crying to me. Almost certainly requires Linux, requires dogtail (and accessibility mode turned on in Gnome (NFI whether KDE has the same features, but it probably does; if you use something other than Gnome or KDE then you’re on your own, you freak)), requires Python and PyGtk, requires Evince (which should be called “Document Viewer”), requires a PDF (that has been exported from OpenOffice.org Impress with notes page included) on the command line, requires a laptop that can do dualhead (mine seems to set up the two screens as One Big Screen, so I don’t know what happens if you have something that actually does it properly), probably requires the phase of the moon to be right as well. Enjoy.

Evince presenter view

import gtk, sys, random, shutil, os, time
from dogtail.tree import root

pdf = sys.argv[1]
# copy pdf to /tmp
pdfcopyname = "pdf.%s.pdf" % random.random()
pdfcopy = "/tmp/" + pdfcopyname
shutil.copy(pdf, pdfcopy)

# start two evinces
os.system("evince --presentation --page-label=1 %s &" % pdf)
os.system("evince %s &" % pdfcopy)

# find them with dogtail
time.sleep(2)
from dogtail.tree import root
evince = root.application("evince")
pdfw = evince.window(os.path.split(pdf)[1])
pdfcopyw = evince.window(pdfcopyname)
halfpages = int(pdfw.child(roleName="tool bar").child(roleName="label").text.split()[1]) / 2
pdfpageel = pdfw.child(roleName="tool bar").child(roleName="text")
pdfcopypageel = pdfcopyw.child(roleName="tool bar").child(roleName="text")

def ping():
  global pdfw, pdfcopyw, halfpages, pdfpageel, pdfcopypageel
  try:
    pdfpage = int(pdfpageel.text)
    pdfcopypage = int(pdfcopypageel.text)
  except ValueError:
    # pdf window has been destroyed, probably
    raise "die"
  if (pdfpage + halfpages) != pdfcopypage:
    pdfcopypage = pdfpage + halfpages
    pdfcopypageel.text = str(pdfcopypage)
    pdfcopypageel.doAction("activate")

  return True


pingobj = gtk.timeout_add(500, ping)
try:
  gtk.main()
except:
  os.unlink(pdfcopy)

More in the discussion (powered by webmentions)

  • (no mentions, yet.)