Hack 11. Liven Up Parties with a Participatory Slideshow

With a laptop, a Bluetooth adapter, and an LCD projector, you can make slideshows of other people's photographs.

Since time immemorial, slideshows have been a dreaded tool of oppression and tedium. Heretofore constrained to only the slides that the presenter wished to show, the slideshow's audience was doomed to mind-numbing boredom, if it turned out that the slides failed to entertain.

Thanks to the ubiquity of mobile phones with both cameras and Bluetooth, the institution of photographic slideshows can now be thrown open, willy-nilly, to the viewing public as both a read and write medium! Allowing people to contribute photos from their phones to a participatory slideshow can offer interesting and often quite entertaining results.

1.12.1. The Slideshow

To set up a participatory slideshow, you'll need a laptop or a PC running Linux, a supported Bluetooth adapter, and an overhead projector. The concept of this hack can certainly be adapted to other operating systems, but the implementation shown here is specific to the Linux Bluetooth stack and to the X11 Window System used on most open source operating systems. The best Linux distros for this purpose are Debian or Ubuntu, because all of the pieces are already available through apt-get.

If you haven't got a Linux PC handy, Ubuntu (http://www.ubuntulinux.org/download) can be installed on an old leftover Pentium in about a half hour. If you use Ubuntu, you'll want to make sure you have the universe and multiverse repositories in your /etc/apt/sources.list. If you're using another version of Linux, you should be able to find the source code and possibly even binary packages for all the software you'll need somewhere on the Net.

Once you've selected a suitable computer, install the BlueZ Bluetooth stack [Hack #1]. Next, plug in your Bluetooth adapter, and make sure the kernel can see it by running dmesg and checking for a suitable notification towards the bottom of the output. (If your Bluetooth adapter is built-in, dmesg | grep -i Bluetooth is your friend.) Next, as root, back up your /etc/bluetooth/hcid.conf and then alter it so that it reads more or less as follows:

	options {
		autoinit yes;
		security none;
		pairing none;
	device {
		name "slideshow";
		class 0x100;
		iscan enable;
		pscan enable;

These settings turn off Bluetooth security (thus allowing anyone to send files to the Bluetooth device), set the name of the device to slideshow, and allow anyone to scan for it. Naturally, once you no longer want anyone sending anything to your computer, you should copy your backup of hcid.conf back into place. Now, as root, run /etc/init.d/bluez-utils restart to restart your Bluetooth manager. On other Linux distros, hcid.conf lives in /etc, rather than /etc/bluetooth, and /etc/init.d/bluez-utils might be called /etc/init.d/bluetooth, instead.

Next, you'll need an OBEX server to receive files sent from people's phones. OBEX is a FTP-like file transfer protocol that runs on top of Bluetooth. A simple OBEX server, quite logically called ObexSERVER, is available using apt-get. The source code for ObexSERVER lives at http://www.frasunek.com/sources/unix/obexserver.c, but you'll need to have the OpenOBEX libraries from http://openobex.sf.net to build it.

You'll also need an image viewer for X11 that supports a slideshow mode. There are a ton of these out there, with the most popular possibly being GQview and feh. Of these two, I prefer GQview, but I'll show how to use feh also. Again, both of them are available using apt-get. If you decide to use GQview, you'll want to load it up, and then go to Edit images/U2192.jpg border=0> Options… to configure the slideshow options on the General tab. Check the Random and Repeat boxes, and set the delay to something short, like five seconds, as shown in Figure 1-25.

Figure 1-25. Setting the slideshow options in gqview

Also, over on the Image tab, you'll probably want to select "Fit image to window" and "Allow enlargement," as shown in Figure 1-26. If you'd rather use feh, we'll see later on that this configuration is done on the command line instead.

Last but not least, you'll need to create an empty directory to hold the contributed slideshow images. I used /home/sderle/slideshow, but any directory you can write to is fine.

Figure 1-26. Setting the default image zoom options in GQview

Finally, seed the slideshow with a single file, which can be an image of anything. The best bet for the seed image is a plain slide that reads "Share your favorite photos by sending them via Bluetooth to 'slideshow'!" You can hack up a slide with some words to that effect using the GIMP in about three minutes. Once everything's configured, you're ready for the code that makes it all go.

1.12.2. The Code

The following shell script accepts images via Bluetooth and displays them in fullscreen mode using GQview:



	xset s off
	xset s noblank
	sdptool add --channel=10 OPUSH

	gqview --slideshow --fullscreen &
	while true; do
		mv /tmp/*.{jpg,JPG} .

First, the calls to xset turn off the X11 screensaver functions, so that it doesn't load the screensaver after some period of inactivity or make the screen go blank. The call to sdptool sets up the Bluetooth channel to receive files via the OBEX PUSH profile.

You might need to run this bit as root first, or change the script to use sudo for that line, and then type in your password when you start the script.

Next, the slideshow script switches to the slideshow image directory; don't forget to change SLIDESHOW_PATH to point to wherever you plan to keep the photos. Once in that directory, the script starts up gqview to run in the background, in fullscreen slideshow mode. Then, the script runs obexserver, which waits for a file to arrive via Bluetooth, and then puts the file into /tmp and quits. Our script moves that file into the current directory, where gqview will automatically detect its presence and add it to the slideshow. Finally, we loop back to run obexserver again, and so on.

Once this script is running, all you need to do is plug the computer into an overhead projector, and you're set. To stop the slideshow, hit Ctrl-Q to get out of gqview, and then Ctrl-C in your terminal to kill the slideshow script.

The nice thing about using GQview, as mentioned earlier, is that it regularly scans the current directory for new files, unlike feh, which scans the directory contents once at startup. If you wanted to use feh instead, you could do the following in the slideshow script, which restarts feh every time a new file arrives:

	while true; do
		feh -D5 -F -z -Z * &
		mv /tmp/*.{jpg,JPG} .
		killall feh

The principle is basically the same, however. The main advantage of this is that it saves you the trouble of having to configure (and possibly later reconfigure) the image viewer just to display a slideshow; the disadvantage is that it increases the likelihood that feh will display some photos with disproportionate frequency, because each time it reloads it loses its idea of which ones it's already shown.

Enjoy your new participatory slideshow! If you use this idea at a party or other gathering, please do let us know how it works out for you.

Schuyler Erle

Bluetooth, Mobile Phones, and GPS

Network Discovery and Monitoring

Wireless Security

Hardware Hacks

Software Hacks

Do-It-Yourself Antennas

Wireless Network Design

Appendix A. Wireless Standards

Appendix B. Wireless Hardware Guide

Wireless Hacks
Wireless Hacks: Tips & Tools for Building, Extending, and Securing Your Network
ISBN: 0596101449
EAN: 2147483647
Year: 2004
Pages: 178

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