Apple IR remote in Ubuntu Hardy

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

Teamspeak start stop script

After my server was restarted twice by my hosting center I decided to make sure Teamspeak would start automatically. I read a few posts on how other people did it but in the end I decided that I created my own minimal script.

My two goals with this init script was:

  • Run the Teamspeak server as an unprivileged user.
  • Make sure the Teamspeak server starts up after reboot even though it wasn’t shut down properly
  • A little bonus was that it reuses much of the init script that is bundled with the installation

Init script (/etc/init.d/teamspeak):

#!/bin/sh

TEAMSPEAK_DIR=/usr/local/teamspeak
TEAMSPEAK_USER=teamspeak

# Make sure that Teamspeak starts even though it wasn't closed nicely last time (ie. by a power cut)
if [ $(su - $TEAMSPEAK_USER -c "ps ux" |grep tsserver2.pid|grep -v grep|wc -l) -eq 0 ] && [ -f ${TEAMSPEAK_DIR}/tsserver2.pid ]
then
    rm ${TEAMSPEAK_DIR}/tsserver2.pid
fi

cd ${TEAMSPEAK_DIR}
su - $TEAMSPEAK_USER -c "./teamspeak2-server_startscript $1"
cd -

My media center

A lot has happened since the last time I blogged… I must admit the main reason for not blogging has been World of Warcraft :)

Anyways back in December my girlfriend and I bought ourselves a new LCD TV capable of displaying HD 1920x1200. To start out with we used our aged Playstation 2 as a DVD player but the low DVD playback quality really shows on the new TV. A few months later I went out and bought a Mac Mini on which I installed Ubuntu.

So far we’ve mainly used it for the slimserver backed for the Squeezebox and occasionally DVD playback in the VLC media player. I’m looking a the different media centers for Linux but haven’t really decided yet. Being a Gnome guy I’m gonna give the next release of Elisa (0.5) a spin when it comes out in july. The earlier releases of Elisa was beautiful and clean but lacking a lot of functionality. So far VLC and a mouse has worked just fine. What I’m really hoping for is some BlueRay playback support in Linux.

Anyways I’m really happy with the Mac Mini as a “Media Center”. I wont be needing any TV Tuners. Its small, good looking, use fairly little power (I think) xD I’m hoping to replace the DVD drive with a BlueRay drive when Linux support picks up at some point.

Migrate emails to Zimbra using imapsync

I’ve installed Zimbra on SLES9 for a costumer because they wanted Zimbra on Suse. The costumer wanted the community maintained version and I felt it was too risky to install Zimbra 5 release candidate.

First a little Suse bashing (sorry but I just get irritated about this over and over again). Zimbra recommends using imapsync to migrate emails to Zimbra and it seems to be a fine piece of software.

  1. I started out by using yast to search for this tool but as I expected nothing.
  2. After downloading it from the website and trying to run it I got a message that I was missing Mail::IMAPClient lib.
  3. I tried to find SLES9 rpm packages (or just RPM packages) with the Mail::IMAPClient lib.
  4. I tried to install this with cpan:

    cpan
    cpan> install Mail::IMAPClient
    ....
    Writing Makefile for Mail::IMAPClient::MessageSet
    Warning: prerequisite Parse::RecDescent 1.94 not found. We have 1.80.
    

    I’m no cpan / perl expert so I couldn’t figure out why I couldn’t get Parse::RecDescent installed.

  5. Anyway what is the benefit of having a supported enterprise version of Suse if you trash it with all sorts of unsupported software.

You could argue that Zimbra should provide imapsync as some part of migration tools.

Anyway the solution was that I installed imapsync on my Ubuntu Gutsy laptop:

sudo apt-get install imapsync

I just gets so disappointed that things are so “hard” in a professional Linux compared to Debian or Ubuntu.

When I’m done I’ll just uninstall it and all its dependencies again:

imapsync libdigest-hmac-perl libdigest-sha1-perl libio-socket-ssl-perl libmail-imapclient-perl libnet-ssleay-perl libparse-recdescent-perl

Important note: I had imapsync on Ubuntu Gutsy hang when it connected to the Zimbra server. I found that passing --noauthmd5 with the example in User Migration in Zimbras wiki made imapsync not hang. An earlier version of Ubuntu (Edgy with an earlier version of imapsync) didn’t need this.

Microsoft will use equipment located in California and other states

I have been meaning to blog about this for a while now. When contacting the Hotmail mail servers to send email your mail server will be presented with strange message in my opinion.

First find the servers which receives email for the hotmail.com domain:

dig mx hotmail.com

which will return something like the following:

hotmail.com.            3600    IN      MX      5 mx1.hotmail.com.
hotmail.com.            3600    IN      MX      5 mx2.hotmail.com.
hotmail.com.            3600    IN      MX      5 mx3.hotmail.com.
hotmail.com.            3600    IN      MX      5 mx4.hotmail.com.

Now try contact one of these on port 25 (just like mail servers does):

telnet mx1.hotmail.com 25

Notice the greetings message from the server:

Sending unsolicited commercial or bulk e-mail to Microsoft's computer network is prohibited.
Other restrictions are found at http://privacy.msn.com/Anti-spam/.
Violations will result in use of equipment located in California and other states. 

Bringing it to peoples attention that sending unsolicited commercial or bulk e-mails is prohibited is fair enought even though I doubt many will read it :) But is it really nessesary to threat to use equipment, and why is California emphasised?