July 26, 2005

Remote application control with Bemused

Author: Nathan Willis

The catalyst for much innovation is laziness. Ask any old person. Years of strenuous room crossing to change TV channels led to the invention of the infrared remote control. Years of strenuous lifting and pointing of these remotes led to the invention of the direction-less RF remote control. Finally, years of strenuous searching for all these remotes has led to the invention of remote control applications for Bluetooth-equipped cell phones. Short of cybernetic implants, this may be the easiest way to control applications without having to touch a keyboard or mouse.

Mac users have had Bluetooth control since 2003, when a series of shareware apps cropped up that took advantage of Mac OS X's built-in Bluetooth support. Salling Clicker, Romeo, and the other apps allowed control of iTunes, the OS X software DVD player, PowerPoint, and miscellaneous system actions. For Windows and Linux users, the equivalent is an open source application called Bemused.

Bemused began life as a controller for WinAmp running on Windows. From there, it was ported to Linux and XMMS, and has since evolved into software with a general purpose client-server model that supports other applications. Utilizing Bemused requires running the server on your PC to listen for commands, and the client on your Bluetooth-enabled phone to send them. The primary distribution contains clients only for Symbian Series 60 and UIQ devices, although ports are available for Palm OS devices and the Java MIDP 2.0 platform (which these days includes most phones and PDAs).

Start me up

You can download the bemusedlinuxserver source (version 1.73 as of this writing) from the project's SourceForge page. To build it, you must have Bluetooth working on your system and both the Bluetooth and XMMS -dev packages installed. (There isn't a configure script that checks for these packages; you'll only be alerted to this need if you try -- and fail -- to compile without them. And, unfortunately, the project has no precompiled binaries for bemusedlinuxserver.) Untar the bemusedlinuxserver package and do a make install. Bemusedlinuxserver is only 76KB in size, it takes seconds to compile, and it doesn't interact with anything system-critical.

After compiling bemusedlinuxserver, you need to configure it. Open /etc/bemused.conf in a text editor and tweak it to your liking: you can specify the path to XMMS, tell Bemused where to look for music files, and decide whether to start XMMS when bemusedlinuxserver launches. Once your changes are made, start the server from a terminal with the command bemusedlinuxserver or with bemusedlinuxserver -d to run the server in daemon mode.

To accomplish anything useful, you'll need to install the client software on your phone. Download the package that fits your phone from the Bemused project page. The installation instructions will, of course, vary depending on your phone's operating system.

Can you hear the music?

Now, with both bemusedlinuxserver and XMMS running on the PC, launch Bemused on your phone. The program has three screens: Playlist, Control, and Browse. On the Control screen, you'll find all the usual XMMS music controls -- hit the play button, and you should hear music from your PC's speakers. (Lest there be any confusion, Bemused does not pipe the music to your phone.) You can navigate the playlist, add songs to it through the Browse screen, and start and stop it from the Control screen.

The playlist should automatically sync with XMMS -- change either one and it will be reflected in both places. Bemused can change the playback volume and set "shuffle" and "repeat" modes, but it does not let you tweak the equalizer settings, so do that before you walk away from the PC.

Depending on your phone, the first time you use Bemused, you may have to go through a Bluetooth pairing step to get a connection. Once the phone knows where to address commands, you shouldn't need to do this again. However, you are at the mercy of your phone manufacturer, which decides how its Bluetooth stack works and may close an inactive connection after a few minutes. Bemused will reconnect as needed.

Another concern is the speed of the Bluetooth connection. The Browse screen loads up the contents of the music directory specified in /etc/bemused.conf, allowing you to add songs to the playlist. If you have several hundred or more files, this can take some time. You can change the preferences to only load the song list as needed and spare yourself this interruption.

And then there are skins. By default, the Bemused Control screen looks a lot like WinAmp. You can download a glut of alternate skins from the Bemused project's site. Like WinAmp and XMMS, Bemused skins are raster-image-based and, for the most part, home-made creations of users. If you've seen what's popular in WinAmp skins, you'll have an idea of what the pickings are like for Bemused as well.

Flip the switch

Once controlling XMMS from across the room no longer wows the neighbors, you can download a newer version of bemusedlinuxserver from the project's CVS repository and take advantage of some key new developments. The latest version supports Xpdf, a flexible PDF file viewer that can operate much like office presentation software.

Xpdf can run full-screen and in "remote server mode," which allows Bemused to issue it commands. To do so, simply launch bemusedlinuxserver on the PC with the -x flag and supply it with the filename you wish to present. Subsequently, the media player buttons in Bemused's Control screen are routed to Xpdf as Page Forward, Page Back, Go To First Page, and so on.

When you've tired of that icebreaker, try using Bemused to control other media players on your Linux system. The CVS version features Linux Infrared Remote Control (LIRC) emulation, providing instant support for a variety of apps, including television viewers such as Xawtv, Kwintv, and Zapping; FM tuners such as RadioDJ and Gnomeradio; and media players such as Xine, MPlayer, and a whole slew of MP3 players. To do this, launch bemusedlinuxserver with the -m flag.

LIRC itself must be installed, and you cannot simultaneously use a real infrared remote control while using bemusedlinuxserver's LIRC emulation. As with Xpdf support, LIRC control uses the media player buttons on your phone's Bemused client program.

Blissfully controlling your Linux box from your cell phone may bring you many admirers, but it will inevitably make you lose some sleep as well, worrying that some ill-mannered hooligan with a Bluetooth phone will walk by and wrest control away from you. The answer to this is the new restricted mode in bemusedlinuxserver CVS. Adding a whitelist of allowed devices to your /etc/bemused.conf file protects you from the ne'er-do-wells, guaranteeing that your phone can connect to the server and ensuring you a peaceful night's sleep.

Click Here!