Remote Control

Control by keyboard and mouse isn't the ideal for a machine like the eBox (ever tried to use a PC without a desk?) so the eBox provides much of its functionality through an infra-red remote control, just as a lot of other entertainment appliances (TVs, VCRs etc.) do. You can even shut down the eBox from the remote, although starting up is not currently possible (however, if someone were interested in building it, it could be done with a little external electronics).

Hardware

You have four options to get IR remotes working with a PC:

I already had an IRMan which I have found to work flawlessly with every remote I have pointed at it, and so I used that initially. However, now that I've got the TV card receiver working I think it's time to retire the IRMan, since I can build the TV card's receiver into the front of the machine and it'll look a bit more tidy. The only disadvantage is that the TV card receiver only seems to support the remote that came with it.

Software

LIRC

The Linux Infra-Red Control project is the way you use infra-red receivers to control just about anything on your Linux box. LIRC provides a set of drivers to accept input from various IR devices, a library that applications can use to support IR control, as well as utilities that enable you to set up keyboard/mouse emulation and run shell commands in response to button presses. LIRC even supports IR transmitters (usually of the home-made variety) to control VCRs or other IR-equipped appliances. There is also a WinLIRC port for Windows.

LIRC works brilliantly - I can control almost all of the functions of XawTV, MPlayer, Xine, and XMMS from the same remote. I have also set it up so I can shut down the machine or eject the disc at the touch of a button. Below I have included instructions on setting up LIRC with the two types of IR receivers I have used.

IRMan Setup

If you're using an IRMan, follow these instructions. Firstly, you'll need to install libirman which is a what LIRC uses to communicate with the IRMan device (usual untar, ./configure, make, and then make install). Once you've done this, you can install LIRC itself. Untar the LIRC source tarball and run ./configure, which will present you with a menu for selecting the device you have. Select Driver Configuration, then Other serial devices, then Irman / UIR. Then you will need to select the serial port that the IRMan is connected to. After that it will return you to the main menu. Select Save configuration & run configure. Then you can do the normal make followed by make install.

One note: I see there is a program called "lirmand" that comes with the libirman package. The description on the libirman page suggests it is for use with LIRC, but I have never needed it, so it's safe to say you don't need to worry about it if you're using LIRC with your IRMan.

TV Card setup

To set up a TV card IR receiver, first make sure the bttv driver module is loaded (see the video capture page for info on how to do this) because the LIRC driver will need it to detect the card you are using. Then untar the LIRC source tarball and run ./configure, which will present you with a menu for selecting the device you have. Select Driver Configuration, then TV card, then the model of TV card you are using. Not all cards that are supported by the bttv driver are listed, but you may be able to get away with using a driver for a similar card. If in doubt, post a question to the LIRC mailing list (please be as descriptive and polite as you can in your message). If your model is there, select it, and you'll end up back at the main menu. Select Save configuration & run configure. Then you can do the normal make followed by make install.

You'll need to have the kernel module for your card loaded. The output of configure should have mentioned which module you'll need to use for your card (for my Dynalink Tview99 it's lirc_gpio). If you add the following line to /etc/modules.conf then it should load automatically (use the correct module name for your card instead of module):

alias char-major-61 module

Configuration

Now that LIRC is installed, you need to set it up. You may be able to find a file for the remote you want to use in the LIRC collection (in remotes.tar.bz2 on the LIRC site, or in the remotes directory included in the main LIRC tarball). Alternatively, you can use the irrecord utility to record the signals from the remote yourself - type irrecord filename, where filename is anything you like, but make it specific to the remote, ie. include the brand name and model number. irrecord is fairly straightforward, just follow the on-screen instructions. Be careful not to try to load the same button twice or miss any buttons, give your buttons sensible names (generally the same label as on the remote is best), and at the end when it asks you to press a button repeatedly, you only need to do it for about 10 seconds or so, and then stop. After another 10 seconds irrecord will time out and save your file. Now copy the file it created to /etc/lircd.conf.

To test your setup, start lircd (which will run in the background) and then irw, which connects to the LIRC device and prints out a message whenever it receives a command it recognises. Check that all the buttons are being recognised. (If you misspelled a name you can just edit the /etc/lircd.conf file with a text editor). It's important to note here that irw will only print out a message for buttons that LIRC recognises. Once you're finished testing, press Ctrl+C to exit irw. You'll want to have lircd starting when your machine starts up, so add a line /usr/local/bin/lircd to your /etc/rc.d/rc.local (or whatever file your distribution uses for this purpose).

Now you need to assign the buttons you've entered in to functions on the machine. This step is highly dependent on what you want to do with the remote and the applications you want to use (for those that support LIRC directly, anyway). Check the documentation for each application to see what names you need to use. Whatever you're doing though, the file you'll need to create/edit will be .lircrc (don't forget the dot) in your home directory. It consists of a number of entries, one for each function, which look like this:

begin
 remote = toshiba-rmv329
 prog = mplayer
 button = PLAY_PAUSE
 config = pause
 repeat = 0
end

remote is the name of the remote you're using - this is the name of the file you created using irrecord (which is also written inside the file, have a look at /etc/lircd.conf if you're not sure). prog is the program name - this is specified internally by each program itself, so check the program's documentation. button is the name of the button you want to assign as entered by you during the irrecord process. config is also specific to the program, and tells the program what you want to do when the button is pressed. repeat is optional, and when set to 1 specifies that holding down the remote button will generate multiple events. This can be useful for things like changing the volume, but not for other types of functions such as play and stop.

I won't go into setting up the various applications with LIRC, except for one program that comes with LIRC itself that allows you to run shell commands in response to pressing buttons. It's called irexec. All you need to do is enter irexec as the value of the prog parameter and the command you want to run in the config parameter of the entry in the .lircrc file. For example:

begin
 remote = as-220
 prog = irexec
 button = POWER
 config = shutdown -h now
end

Of course, you'll need to be running irexec for functions such as this to work when you press the button (start it with irexec -d so that it runs in the background - add it to your /etc/rc.d/rc.local so that it runs on start-up). If you use this method for a lot of buttons, it's best to set up shell scripts and attach those instead so you don't have to edit .lircrc all the time. For example, I have a script called shutdown-script (available in the files if you're interested) which first checks to see if any of the applications I use on the eBox are running, and if none of them are then it shuts down the machine. This way, if you accidentally hit the button during a movie it won't do anything.

You can assign the same button to multiple programs, as long as the two programs will never be running at the same time. If you are adventurous and feel the need, you can work around this by using LIRC's modes feature, but in my experience it hasn't worked very well so it's best to set up your buttons so that you don't get conflicts.



Home | News | Status | Current Hardware | Pictures | Why Linux? | Resources
Playing Movies | Playing Music | Video Capture | Remote Control | Hardware Mods | Software Setup