Sunday, May 25, 2008

remote control




I just got a remote control for my computer, and it is so sweet. I don't have to get up to adjust the volume between each podcast, and I have it all hooked up to MPlayer, amixer and Enlightenment.

I decided to get the Microsoft Media Center Remote, it hooks up via USB to your computer, and is well supported under Linux. It has a very nice ergonomic button layout and feel in your hand, which is the most important thing.

Under Fedora 8, you first need to get the atrpms yum repository installed. To do this, you first import the atrpms keys:


rpm --import http://ATrpms.net/RPM-GPG-KEY.atrpms


and then put the following lines in /etc/yum.conf:


[atrpms]
name=Fedora Core $releasever - $basearch - ATrpms
baseurl=http://dl.atrpms.net/f$releasever-$basearch/atrpms/stable
gpgkey=http://ATrpms.net/RPM-GPG-KEY.atrpms
gpgcheck=1


Then, you install lirc with yum:


yum install lirc lirc-lib lirc-lib-devel


and install the module into your kernel:


modprobe lirc_mceusb2


Then, get this file and copy it to /etc/lircd.conf:


http://lirc.sourceforge.net/remotes/mceusb/lircd.conf.mceusb


After this, you start lircd:


/etc/rc.d/init.d/lircd start


To have it automated at startup,

1. Add the below to /etc/modprobe.conf

alias char-major-61 lirc_mceusb2


2. Set the service to start on boot:

/sbin/chkconfig lircd on


To check to see if your remote control is working, and what buttons correspond to which symbols, type:


irw


When you press buttons on your remote control, you'll see something like:


siddhidatri 144 [~] % irw
000000037ff07bed 00 ChanUp mceusb
000000037ff07bec 00 ChanDown mceusb
000000037ff07bec 01 ChanDown mceusb
000000037ff07bec 02 ChanDown mceusb
000000037ff07bf1 00 Mute mceusb
000000037ff07bf1 01 Mute mceusb
000000037ff07be9 00 Play mceusb
000000037ff07be9 01 Play mceusb
000000037ff07be9 02 Play mceusb
000000037ff07bf1 00 Mute mceusb
000000037ff07bf1 01 Mute mceusb
000000037ff07bfe 00 One mceusb
000000037ff07bfe 01 One mceusb
000000037ff07bfd 00 Two mceusb
000000037ff07bfd 01 Two mceusb
000000037ff07bfd 02 Two mceusb
000000037ff07bfc 00 Three mceusb
000000037ff07bfc 01 Three mceusb


To get MPlayer to listen to your remote control, enable LIRC support when you build it:


cd MPlayer-1.0rc1/
./configure --prefix=/usr/sness/mplayer --enable-lirc
make
make install


To get other programs, like eesh from Enlightenment to listen to your remote control, use irexec. You configure irexec by adding definitions to this file.

My current ~/.lircrc looks like:


begin
button = VolUp
prog = irexec
repeat = 1
config = amixer -c 0 -- sset Master playback 1+
end
begin
button = VolDown
prog = irexec
repeat = 1
config = amixer -c 0 -- sset Master playback 1-
end
begin
button = ChanUp
prog = mplayer
repeat = 1
config = volume 1
end
begin
button = ChanDown
prog = mplayer
repeat = 1
config = volume -1
end
begin
button = Mute
prog = mplayer
repeat = 0
config = mute
end
begin
button = Pause
prog = mplayer
repeat = 0
config = pause
end
begin
button = Home
prog = mplayer
repeat = 0
config = pause
end
begin
button = Skip
prog = mplayer
repeat = 0
config = seek 1000
end
begin
button = Replay
prog = mplayer
repeat = 0
config = seek -1000
end
begin
button = More
prog = mplayer
repeat = 0
config = osd
end
begin
button = Rewind
prog = mplayer
repeat = 1
config = seek -10
end
begin
button = Forward
prog = mplayer
repeat = 1
config = seek +10
end
begin
button = Play
prog = mplayer
repeat = 1
config = play
end
begin
button = Stop
prog = mplayer
repeat = 1
config = quit
end
begin
button = Enter
prog = irexec
repeat = 0
config = /bin/zsh -c 'xscreensaver & ; xscreensaver-command -activate'
end
begin
button = Clear
prog = irexec
repeat = 0
config = xscreensaver-command -exit
end
begin
button = Guide
prog = irexec
repeat = 0
config = /bin/zsh -c 'eesh -e "goto_desktop 1" && eesh -e "goto_area 0 0"'
end
begin
button = RecTV
prog = irexec
repeat = 0
config = /bin/zsh -c 'eesh -e "goto_desktop 3" && eesh -e "goto_area 0 1"'
end
begin
button = LiveTV
prog = irexec
repeat = 0
config = /bin/zsh -c 'eesh -e "goto_desktop 3" && eesh -e "goto_area 0 0"'
end
begin
button = DVD
prog = irexec
repeat = 0
config = /bin/zsh -c 'eesh -e "goto_desktop 0" && eesh -e "goto_area 1 1"'
end