24 Aug 2008

Apple IR remote in Ubuntu Hardy

Posted by Jacob Emcken

This weekend I decided to try and get my Apple remote to work on my Mac mini which I just upgraded to Hardy the other day.

Configuring the package lirc you are able to select the apple remote from a list but I couldn’t get it to work that way. So I found a way to create my own configuration file for the Apple remote:

sudo irrecord -H macmini -d /dev/usb/hiddev0 macmini.conf

-H tels irrecord which driver to use -d is the device irrecord listens for input on macmini.conf is the file where irrecord saves the configuration when done

First you need to hold a button. I had to wait almost 25 sec before it was satisfied and went on with the configuration. Now just follow the on screen instructions and in the end you should have you own configuration file. I recommend to compare the following file with the one you just created to check out the differences:

/usr/share/lirc/remotes/apple/lircd.conf.macmini

I made sure to call my buttons the same as in lircd.conf.macmini.

After that I altered these two files to point to my newly created configuration file and removed pointers to lircd.conf.macmini:

hardware.conf
lircd.conf

I then restarted lircd with:

sudo /etc/init.d/lirc restart

now you should be able to check that it is working with the command irw:

irw

Just Ctrl+c when you are satisfied with the result.

At some point I would like to use my remote with Elisa which just released a 0.5.6 which have DVD playback support, but for now I’ll just stick to Totem just to try getting it to work.

To use the remote in Totem you first have to enable the IR plugin (Edit -> Plugins…). Then you have to configure what to buttons are supposed to do which is done in a configuration file in you home folder:

~/.lircrc

Content could look something like this (read more about syntax on LIRC’s website):

begin
    prog = Totem
    remote = Apple_A1156
    button = vol+
    config = volume_up
end

Since the Apple remote have a combined Play/Pause button I wanted to find out if that was possible. I had a bit of trouble figuring out what was going in the config = line and looked through all documentation I could find on LIRC’s website. Suddenly it hit me that the values in config a specific for the application. Not much about this on the Totem website so I downloaded the source code for Totem. Don’t worry this isn’t going to be hardcore. I unpacked the source code and searched for files with the name lirc:

$ cd totem-2.22.1
$ find . -name \*lirc\*
./data/lirc_example
./src/plugins/lirc
./src/plugins/lirc/totem-lirc.c
./src/plugins/lirc/lirc.totem-plugin.in

I opened the file totem-lirc.c and found about 25 definitions for IR commands something like the following:

#define TOTEM_IR_COMMAND_PLAY "play"
#define TOTEM_IR_COMMAND_PAUSE "pause"
#define TOTEM_IR_COMMAND_NEXT "next"
#define TOTEM_IR_COMMAND_PREVIOUS "previous"
#define TOTEM_IR_COMMAND_SEEK_FORWARD "seek_forward"
#define TOTEM_IR_COMMAND_SEEK_BACKWARD "seek_backward"
#define TOTEM_IR_COMMAND_VOLUME_UP "volume_up"
#define TOTEM_IR_COMMAND_VOLUME_DOWN "volume_down"
#define TOTEM_IR_COMMAND_FULLSCREEN "fullscreen"
#define TOTEM_IR_COMMAND_QUIT "quit"
#define TOTEM_IR_COMMAND_UP "up"
#define TOTEM_IR_COMMAND_DOWN "down"
#define TOTEM_IR_COMMAND_LEFT "left"
#define TOTEM_IR_COMMAND_RIGHT "right"
#define TOTEM_IR_COMMAND_SELECT "select"
#define TOTEM_IR_COMMAND_MENU "menu"
#define TOTEM_IR_COMMAND_PLAYPAUSE "play_pause"
#define TOTEM_IR_COMMAND_ZOOM_UP "zoom_up"
#define TOTEM_IR_COMMAND_ZOOM_DOWN "zoom_down"
#define TOTEM_IR_COMMAND_SHOW_PLAYING "show_playing"
#define TOTEM_IR_COMMAND_SHOW_VOLUME "show_volume"
#define TOTEM_IR_COMMAND_EJECT "eject"
#define TOTEM_IR_COMMAND_PLAY_DVD "play_dvd"
#define TOTEM_IR_COMMAND_MUTE "mute"
#define TOTEM_IR_COMMAND_TOGGLE_ASPECT "toggle_aspect"

Other multimedia software might be better docuemented when it comes to IR but I guess you would be able to use something similar to figure out what possible config-options you have in the lircrc for the software.

Anyways Totem have a Play/Pause toggle and I ended up with:

begin
    prog = Totem
    remote = Apple_A1156
    button = play
    config = play_pause
end

5 Comments to Apple IR remote in Ubuntu Hardy

Jacob Emcken
August 25, 2008

I found a Blog entry about some of the same stuff:

http://jaykinzer.blogspot.com/2008/02/setting-up-remote-control-lirc.html

This guys use a tool in Ubuntu called mythbuntu-lirc-generator which can generate lircrc configuration for several applications.

Russ
September 20, 2008

DUDE! Holy crap it took me all night to find this page. Thank you, I couldn’t get my mac mini remote working in Hardy otherwise, Thanks a million for posting this.

Scaine
November 16, 2008

Do you find that when you reboot your MacMini, it sometimes fails to load LIRC correctly? I do and I’ve found that it’s because I have two /dev/usb/hiddev devices (0 and 1) and I need to choose one to go into hardware.conf.

The problem seems to be that the Mac internally will activate only one of these and if it’s not the one I have in hardware.conf, I need to edit, then restart LIRC. It’s minor, but it’s irritating.

Jacob Emcken
February 5, 2009

I rarely reboot the Mac Mini so I havn’t noticed this.

Roque Pinel
February 5, 2011

Check out this GNOME applet.

http://code.google.com/p/ir-switcher/

Leave a comment