Hack 76 Create a Trade Show Demo


figs/moderate.gif figs/hack76.gif

I frequently represent NetBSD at trade shows. It's challenging to attract attention because there are many booths at a show people will walk by quickly unless something catches their eye. You also need to balance eye-candy with functionality so that you can attract and keep a visitor's attention. I needed an enticing demo to run on one of the computers in the booth.

I wanted to show off several applications, such as office productivity tools, video, and games, and have music playing, but there's only so much screen real estate. Cramming all of those things on the screen at once would clutter the screen, and the point would be lost.

Most X window managers have some concept of virtual desktops, separate work spaces that you can flip between. For example, Enlightenment (pkgsrc/wm/enlightenment) not only has the concept of virtual desktops, but as an added bonus for the trade show environment offers a nice sliding effect as you transition from one desktop to the next.

7.9.1 Introducing eesh

Normally in Enlightenment, to switch from one virtual desktop to the next, you move the mouse pointer to the edge of the screen and then push past it, or you use a key sequence to move to an adjacent desktop. For an unattended demo, we need to automate this process. Enlightenment provides an undocumented utility called eesh that can control most aspects of the Enlightenment window manager. You can write scripts to move windows, resize them, or flip between desktops.

Note that eesh isn't a friendly utility; it doesn't even produce a prompt when you run it. Type help for the menu or exit to quit:

% eesh help Enlightenment IPC Commands Help commands currently available: use "help all" for descriptions of each command use "help <command>" for an individual description actionclass             active_network          advanced_focus   sfa   autosave                background              border                 button                  button_show             colormod               configpanel             copyright               current_theme    tc    cursor                  default_theme           dialog_ok        dok   dock                    dump_mem_debug          exit             q     focus_mode       sf     fx                      general_info           geominfo_mode    sgm    goto_area        sa     goto_desktop     sd    group            gc     group_info       gl     group_op         gop   help             ?      imageclass              internal_list    il    list_class       cl     list_remember           list_themes      tl    module                  move_mode        smm    nop

Unfortunately, the eesh utility seems to be untested. It sometimes behaves inconsistently by not accepting commands until you enter them a second time or by withholding output until you press Enter again. As an example, there are actually more commands than those indicated in the help listing. Look in the Enlightenment source's ipc.c file for a complete list.

7.9.2 Discovering Commands

We'll start our script by making sure that Enlightenment is configured the way we want for our demo. We want six work spaces (3 by 2) to display our programs. Within eesh, try the following commands:

num_areas ? Number of Areas: 2 2 help num_areas Enlightenment IPC Commands Help : num_areas (sna) -------------------------------- Change the size of the virtual desktop Use "num_areas <width> <height>" to change the size of the virtual desktop. Example: "num_areas 2 2" makes 2x2 virtual destkops Use "num_areas ?" to retrieve the current setting num_areas 3 2

Now we have the number of areas we want. areas is the Enlightenment name for virtual desktops, since Enlightenment also supports multiple desktops, but that's different. Now we'd like our screen to display the first area, so that the programs our script runs will open there:

goto_area 0 0

If your terminal wasn't on the first area, it just moved off the screen. Use the mouse to return to that area.

eesh also lets us write commands on the command line with the -e (execute command) flag:

% eesh -e "goto_area 0 0"

7.9.3 Sample Scripts

Now we know enough to write a simple demo script:

#!/bin/sh eesh -e "num_desks 1" eesh -e "num_areas 3 2" sleep 1 eesh -e "goto_area 0 0" # Configure the default gqmpeg playlist to play your desired music gqmpeg # Show an interesting avi file. xanim -geometry +50x+10 netbsd3.avi & # Give the programs time to start, to make sure they  # open on the correct area. # Also, lets people watching see what started up. sleep 3 eesh -e "goto_area 1 0" # Word Processing abiword sampledoc.abw & sleep 2 eesh -e "goto_area 2 0" # Spreadsheet gnumeric samplesheet.gnumeric & sleep 2 eesh -e "goto_area 0 1" # A lively game battleball & sleep 2 eesh -e "goto_area 1 1" # Web Browsing (of a local hierarchy, in case you don't have net  # connectivity at a trade show) firebird file://index.html & sleep 3 eesh -e "goto_area 2 1" sleep 1 # Insert your favorite application here # Leave screen back at page 1. eesh -e "goto_area 0 0"

When you run the script, the screen will slide around to the various areas and pause a few seconds between program launches. We have most of the things we wanted: music, video, and applications. The next step is to keep it moving. Try the following script:

#!/bin/sh while [ 1 ] do         eesh -e "goto_area 0 0"         sleep 2         eesh -e "goto_area 1 0"         sleep 2         eesh -e "goto_area 2 0"         sleep 2         eesh -e "goto_area 0 1"         sleep 2         eesh -e "goto_area 1 1"         sleep 2         eesh -e "goto_area 2 1"         sleep 2 done

To stop the moving display, you have to get your keyboard focus into the xterm where the script is running so that you can press Ctrl-c. That can be difficult, but we'll address it shortly.

7.9.4 More Complex Scripts

For a complex demonstration, you can have different sets of these scripts that visit different sets of areas. You can also change the delay so that complex areas display for a longer period. I also made a script that clears all of the viewing areas. That way, when visitors to the booth play around with the machine, I can easily reset to a clean state and then start the demo again.

Since many of the utilities you'll demonstrate don't create .pid files, I find it easiest to use pkill, the "kill process by name" utility. (FreeBSD provides killall.)

I'll also leave you with two example scripts that show how to extract information about Enlightenment's current settings for use in a more complex script.

The first script is retitle:

#!/bin/sh WIN=`eesh -ewait "set_focus ?" | sed 's/^focused: //' ` xterm -geometry 47x7+227+419 -fn -*-courier-*-o-*-*-34-*-*-*-*-*-*-* -e \ /home/david/bin/retitle2 $WIN

The second is retitle2:

#!/bin/sh WIN=$1 echo "enter new title:" read TITLE eesh -e "win_op $WIN title $TITLE"

With these scripts and e16keyedit , you can bind a key combination to change the title of any window. This makes it much easier to keep track of xterms, if you prefer task-oriented titles.

Now back to the control issue. When I first wrote this demo, I used a switch wired to a serial port to start and stop the demo so that keyboard focus did not matter. However, wiring switches is more work than configuring software, so I found a better way.

The e16keyedit utility, written by Geoff "Mandrake" Harrison and Carsten "Raster" Haitzler (the primary developers of Enlightenment), allows you to bind function keys and Meta keys to run programs or perform the same functions that you can with eesh. Using e16keyedit, you can define function keys to set up the demo, clean up the demo, and start and stop the area rotations. Since the function keys can be bound to work anywhere within Enlightenment, keyboard focus no longer matters. You're ready to give a fantastic demo!

e16keyedit is not part of the main Enlightenment distribution. Download it from SourceForge (http://sourceforge.net/project/showfiles.php?group_id=2).

7.9.5 See Also

  • The Enlightenment web site (http://www.enlightenment.org/)



BSD Hacks
BSD Hacks
ISBN: 0596006799
EAN: 2147483647
Year: 2006
Pages: 160
Authors: Lavigne

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net