Re-installing lirc and getting the MCE Remote working again

6 10 2014

About a year ago, I had installed lirc to get the Microsoft Media Center receiver and remote working with my Linux box. I haven’t touched these things again and upgraded the system in the meantime, but now I wanted to use these things again. First thing that I had to do, of course, was to emerge lirc

I still had my old config files in ~/.lirc that I had been auto-generating with the mythbuntu-lirc-generator, hoping that I’d be able to instantly use them out of the box. This proved not to be the case. So I checked if the module was loaded correctly and the USB interface working with lsmod | grep lirc
lsmod | grep mce
which they were and tested if I am receiving anything from the remote with

It turned out that the remote was working, but what it was sending didn’t correspond with the keys in my config files anymore. The lirc people decided to rename all of the keys and hence my applications were unable to recognize the remote.

To fix this, I checked online sources for what had changed, then decided to do a search-and-replace job to update my config files to use the new key aliases. The following two commands are what it boiled down to, which I could copy+paste inside of my .lirc directory:
grep "Was:" lircd.conf.mceusb | awk -F"# Was: " '{print $2 $1}' | sed -E "s/ +/ /g" | awk '{print "sed -i \"s/button = "$1"/button = "$2"/Ig\" *"}' | sort -r | uniq -i

(you should check for a version of this file which is closest to my posting date – the last one that I can find from 2013 doesn’t show the changes yet)

This spewed out the following replacements:
sed -i "s/button = Zero/button = KEY_0/Ig" *
sed -i "s/button = Yellow/button = KEY_YELLOW/Ig" *
sed -i "s/button = VolUp/button = KEY_VOLUMEUP/Ig" *
sed -i "s/button = VolDown/button = KEY_VOLUMEDOWN/Ig" *
sed -i "s/button = Videos/button = KEY_VIDEO/Ig" *
sed -i "s/button = Up/button = KEY_UP/Ig" *
sed -i "s/button = Two/button = KEY_2/Ig" *
sed -i "s/button = TV/button = KEY_TV/Ig" *
sed -i "s/button = Three/button = KEY_3/Ig" *
sed -i "s/button = Teletext/button = KEY_TEXT/Ig" *
sed -i "s/button = Stop/button = KEY_STOP/Ig" *
sed -i "s/button = Start/button = KEY_PLAY/Ig" *
sed -i "s/button = Star/button = KEY_NUMERIC_STAR/Ig" *
sed -i "s/button = Skipfwd/button = KEY_FASTFORWARD/Ig" *
sed -i "s/button = Skip/button = KEY_NEXT/Ig" *
sed -i "s/button = Skipback/button = KEY_REWIND/Ig" *
sed -i "s/button = Six/button = KEY_6/Ig" *
sed -i "s/button = Seven/button = KEY_7/Ig" *
sed -i "s/button = Right/button = KEY_RIGHT/Ig" *
sed -i "s/button = Rewind/button = KEY_REWIND/Ig" *
sed -i "s/button = Replay/button = KEY_AGAIN/Ig" *
sed -i "s/button = Red/button = KEY_RED/Ig" *
sed -i "s/button = RecTV/button = KEY_RECORD/Ig" *
sed -i "s/button = Record/button = KEY_RECORD/Ig" *
sed -i "s/button = Rec/button = KEY_RECORD/Ig" *
sed -i "s/button = Radio/button = KEY_RADIO/Ig" *
sed -i "s/button = Power/button = KEY_POWER/Ig" *
sed -i "s/button = PlayPause/button = KEY_PLAYPAUSE/Ig" *
sed -i "s/button = Play/button = KEY_PLAY/Ig" *
sed -i "s/button = Pictures/button = KEY_IMAGES/Ig" *
sed -i "s/button = Pause/button = KEY_PAUSE/Ig" *
sed -i "s/button = One/button = KEY_1/Ig" *
sed -i "s/button = OK/button = KEY_OK/Ig" *
sed -i "s/button = Nine/button = KEY_9/Ig" *
sed -i "s/button = Mute/button = KEY_MUTE/Ig" *
sed -i "s/button = Music/button = KEY_AUDIO/Ig" *
sed -i "s/button = LiveTV/button = KEY_TV/Ig" *
sed -i "s/button = Left/button = KEY_LEFT/Ig" *
sed -i "s/button = Home/button = KEY_HOME/Ig" *
sed -i "s/button = Hash/button = KEY_NUMERIC_POUND/Ig" *
sed -i "s/button = Guide/button = KEY_INFO/Ig" *
sed -i "s/button = Green/button = KEY_GREEN/Ig" *
sed -i "s/button = Fwd/button = KEY_FORWARD/Ig" *
sed -i "s/button = Four/button = KEY_4/Ig" *
sed -i "s/button = Forward/button = KEY_FORWARD/Ig" *
sed -i "s/button = Five/button = KEY_5/Ig" *
sed -i "s/button = Enter/button = KEY_ENTER/Ig" *
sed -i "s/button = Eject/button = KEY_EJECTCD/Ig" *
sed -i "s/button = Eight/button = KEY_8/Ig" *
sed -i "s/button = Dvdmenu/button = KEY_MENU/Ig" *
sed -i "s/button = DVD/button = KEY_DVD/Ig" *
sed -i "s/button = Down/button = KEY_DOWN/Ig" *
sed -i "s/button = Clear/button = KEY_CLEAR/Ig" *
sed -i "s/button = Chup/button = KEY_CHANNELUP/Ig" *
sed -i "s/button = Chdown/button = KEY_CHANNELDOWN/Ig" *
sed -i "s/button = ChanUp/button = KEY_CHANNELUP/Ig" *
sed -i "s/button = ChanDown/button = KEY_CHANNELDOWN/Ig" *
sed -i "s/button = \*/button = KEY_NUMERIC_STAR/Ig" *
sed -i "s/button = #/button = KEY_NUMERIC_POUND/Ig" *
sed -i "s/button = Blue/button = KEY_BLUE/Ig" *
sed -i "s/button = Back/button = KEY_BACK/Ig" *
sed -i "s/button = 9/button = KEY_9/Ig" *
sed -i "s/button = 8/button = KEY_8/Ig" *
sed -i "s/button = 7/button = KEY_7/Ig" *
sed -i "s/button = 6/button = KEY_6/Ig" *
sed -i "s/button = 5/button = KEY_5/Ig" *
sed -i "s/button = 4/button = KEY_4/Ig" *
sed -i "s/button = 3/button = KEY_3/Ig" *
sed -i "s/button = 2/button = KEY_2/Ig" *
sed -i "s/button = 1/button = KEY_1/Ig" *
sed -i "s/button = 0/button = KEY_0/Ig" *

After that was done, I checked if everything was done correctly for the programs that concerned me most, vlc and totem:
grep -o "button =.*" vlc totem | awk -F":" '{ print $2 }' | sort | uniq
and manually edited/deleted the entries which looked odd. After restarting lirc, everything worked again!


Kubuntu (KDE) together with Ubuntu 9.10

4 12 2009

I really do like the new Ubuntu, but there are some things that KDE has which it doesn’t offer. For one thing, the kio_slaves and Kate, the best free text editor that I used so far. I have considered installing Kubuntu in parallel to Ubuntu, but neither a shared home directory for them nor two home directories sounds intriguing. You can have both desktop environments by apt-get install kubuntu-desktop

Then you’ll be able to select KDE as window manager when logging in to your account. This will also replace the bootsplash theme in your initramfs that you see during bootup with Kubuntu’s theme, though. If you want to get the old one back: sudo update-usplash-theme usplash-theme-ubuntu

While we’re concerned with boot options, fiddling around with grub2 is beginning to grow into a rather complex task. What’s easier: Controlling your boot menu through the Startup manager.

Ubuntu 9.10 on a HP Compaq Presario CQ71 Notebook PC

4 12 2009

This is the second time that my IBM Thinkpad R51 died on me, and since I love it dearly but the hardware is outdated by now, I bought a Hewlett-Packard Compaq Presario CQ71 Notebook PC. Since the 9.10 version of Ubuntu, dubbed “Karmic Koala”, was released recently, I decided to try it out. It’s really nice – things like the integrated webcam work out of the box on my notebook, e.g. through Cheese. What didn’t work too well, though, was audio.

Apparently that’s a problem with the snd-hda-intel module. The built-in card identifies as follows:
# cat /proc/asound/card0/codec#* | grep Codec
Codec: IDT 92HD75B2X5
Codec: Intel G45 DEVCTG

There are numerous tips out there how to fix this problem that ALSA has with the snd-hda-intel model, most of them involve editing your /etc/modprobe.d/alsa-base.conf in a desperate attempt to find the right combination of options to get it working. I suggest before you try experimenting, you try what I did: install linux-backports-modules-alsa-karmic-generic via apt-get install linux-backports-modules-alsa-karmic-generic For me, this made my audio start working out of the box again without any more changes.

Automated logging of TBs and GeoCoins at

16 11 2009

I have taken up a new hobby called Geocaching some months ago, where you run around with a GPS device in order to find hidden “caches” along the countryside. One thing that you can find in these caches are so-called “trackables” which own a tracking number. You enter this tracking number on the website to claim that you have seen and maybe have taken the trackable item.

When attending an event together with other Geocachers, the number of trackable items present can become really big – there were over 80 of them for the last get-together that I went to. Since I don’t want to track all of these items by hand, I remembered about the possibility to automate web browsers with Selenium. After I got a list of the tracking numbers, I wrote a small script to handle the “Discover It!” requests to the website.
Read the rest of this entry »

My true political self

30 09 2009
You are a
Social Moderate
(55% permissive)

and an…

Economic Liberal
(28% permissive)

You are best described as a:


Link: The Politics Test on Ok Cupid

Bit hack optimizations

20 05 2008

I came across Sean Eron Anderson’s Bit Twiddling Hacks page today, where all these awkward optimizations are collected that are faster than generated machine code from the compiler for common tasks. Using those was common practice when people were still coding in Assembler and needed to get the most out of their CPUs, and it probably still finds use in programming today when speed is of the essence.

A link on that page went to Paul Hsie’s Assembly Language Lab where you can find fast code for dividing by a constant and multiplying with a constant. The latter page has a warning that because it is over 235K of HTML, browsers may fail to render the page correctly. Very cute. 🙂

Help with regular expressions

4 05 2008

Mastering regular expressions can quickly become a non-trivial task. While good text editors like e.g. Kate, KWrite or TextPad have good support for regular expressions, it can be difficult to construct complex regexps, and even more so to find out why they don’t work as intended if they fail.

I have found two resources which help with that: first, the Javascript Regular Expression Validator from net shift media, which takes a regular expression from you and provides two input fields for tests which can be matched against the expression – instantly, no need to press any buttons and wait for an answer. This is very handy to find out if there was a typo in your logic somewhere.

If you need more help in debugging your expressions, then Dr. Edmund Weitz’s RegEx Coach might be able to help. This Windows program (there’s an outdated, discountinued Linux version, too) will take you through the evaluation of your regular expression, step by step:

The Regex Coach screenshot