HowTo: Launch and terminate an Impress (PowerPoint) presentation from a Terminal

The scenario is simple: You have a kiosk or display machine showing information, eg: a self-updating webpage. On a schedule you want to launch an Impress or PowerPoint presentation on the display which will loop. You want that loop to only run for a few minutes before terminating and going back to what was originally being displayed.

How do you do this?


Procedure:

  1. First of all you need a presentation file. If the original is from PowerPoint, load it into Impress and re-save it as an ODP file.
  2. Make sure that your presentation has been cleared of all “On Click” events, ie: All slides should advance automatically after X seconds. Any animated components within a slide should be updated to occur after the last action.
  3. Make sure your presentation is set to automatically loop at the end (Slideshow Menu->SlideShow Settings->Type set to Auto with zero seconds).
  4. Save your changes.
  5. Copy your presentation over to your kiosk machine.
  6. Using SSH or a local terminal, bring up the crontab into your favourite text editor (default is Nano with Ubuntu) with:

    $ crontab -e
  7. Now, assuming your presentation is at /home/kiosk/Documents/MyPreso.odp, add  the following lines:

    00 10 * * * DISPLAY=:0 /usr/lib/libreoffice/program/simpress -show /home/dashboard/Documents/MyPreso.odp --norestore
    15 10 * * * /usr/bin/killall soffice.bin


    What the above lines will do is launch Impress to open your MyPreso presentation in Show Mode at 10:00am on the dot on the first display (screen zero). The “–norestore” parameter prevents LibreOffice from asking if you want to recover any files which will occur if you terminate LibreOffice instead of closing the app as normal (we can’t because it’s a kiosk, remember?). Then, at 10:15am, the LibreOffice task will be terminated, thus ending the looping presentation.
  8. Now save your changes and exit the text editor. if using Nano, you’d press CTRL+X, then “Y” and then Enter
  9. Now test your schedule.

That’s cool. Now can we configure it to have a different presentation to run each day?

This is quite easy to do.

  1. First generate all the different presentations you will need to run on each day of the week. Name them accordingly. In this example we are naming them MyMondayPreo.odp, MyTuesdayPreso.odp, and so forth.
  2. Now modify the crontab to look like the following:

    00 10 * * 1 DISPLAY=:0 /usr/lib/libreoffice/program/simpress -show /home/dashboard/Documents/MyMondayPreso.odp --norestore # Monday
    00 10 * * 2 DISPLAY=:0 /usr/lib/libreoffice/program/simpress -show /home/dashboard/Documents/MyTuesdayPreso.odp --norestore # Tuesday
    00 10 * * 3 DISPLAY=:0 /usr/lib/libreoffice/program/simpress -show /home/dashboard/Documents/MyWednesdayPreso.odp --norestore # Wednesday
    00 10 * * 4 DISPLAY=:0 /usr/lib/libreoffice/program/simpress -show /home/dashboard/Documents/MyThusdayPreso.odp --norestore # Thursday
    00 10 * * 5 DISPLAY=:0 /usr/lib/libreoffice/program/simpress -show /home/dashboard/Documents/MyFridayPreso.odp --norestore # Friday
    15 10 * * * /usr/bin/killall soffice.bin


    You will notice that each line has one of the asterisks replaced with a number 1 through 5. This tells cron only to run that schedule on the day specified. In this case, the 1 represents Monday, the 2 is Tuesday, the 3 is Wednesday and so forth. Saturday is 6 and Sunday is both 1 or 7.

    You may be wondering why we only have one killall command instead of five? We don’t need five as the command to kill LibreOffice is the same each time, so it doesn’t need a day designation – it will run every day at 10:15am.
  3. Save your changes and test.

Now you can schedule your presentations to appear and disappear as required without manually interrupting the normal display on that kiosk. Naturally these instructions can be adapted for other uses.