Showing post in category: Linux

24 Aug 2008

Apple IR remote in Ubuntu Hardy

Posted by Jacob Emcken Comments (5)

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

22 Jul 2008

Teamspeak start stop script

Posted by Jacob Emcken Comments (0)

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 -

30 Oct 2007

Migrate emails to Zimbra using imapsync

Posted by Jacob Emcken Comments (0)

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::IMAPClientlib.
  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.

18 Oct 2007

Bash prompt pimping

Posted by Jacob Emcken Comments (0)

Today at work over lunch I read an article in Linux Magazine called Pimped Prompt.

It inspired me to try different stuff out. I often missed an indication on when I was doing different stuff in the terminal… this is what I ended up with:

export PS1='\[\e[0;34m\][\@\e[1D]\[33[0m\] \u@\h:\w\$ '

This is how it looks like.

To make it permanent put it in your .bashrc file in your home directory. Remember that this variable is propably already set so you either need to replace the line or instert closer to the bottom of the file.

13 Sep 2007

Mass converting flac to mp3 with Gstreamer from cli

Posted by Jacob Emcken Comments (1)

I’m extracting all my CD’s to flac files but my girlfriend is using iPod and iTunes on Windows which won’t play flac files. So I looked into converting all the music to mp3 so she could use it as well. I wanted a way to do it from the command line and I knew Gstreamer was up for the job:

gst-launch-0.10 filesrc location="music.flac" ! flacdec ! audioconvert ! lame ! id3mux name=tag v2-tag=true v1-tag=true ! filesink location="music.mp3"

The cool thing is that tags is preserved.

Note: Actually first I thought tags wasn’t preserved during the the gstreamer conversion, but that was because I used Totem with the Xine backend which apparently cant show mp3 tags.

Now I only need to write a bash script to run through all the music… lets see when I find the time :D

15 May 2007

SCO with the freedom of Windows… wtf?!

Posted by Jacob Emcken Comments (0)

At work today I found an old SCO evaluation CD. A paragraph at the back of the CD cover made me laugh:

> SCO – a tightly integrated set of products which give you the best of both worlds – the power and reliability of UNIX and the freedom of Windows.

The “freedom” of Windows… what is that? :-O Click on the link below for full image.

10 May 2007

Now I’m a Novell Certified Linux Professional (CLP)

Posted by Jacob Emcken Comments (1)

This week I’ve been on a course to prepare for the Novell Certified Linux Engineer (CLE) which is required (and payed) by my employer. But to take the CLE certification test you need to be CLP certified first, so today I took the CLP certification. Now I’m ready to do the CLE tomorrow.

I’ve been working with Linux for some years now so the test wasn’t really that hard. Actually I was disappointed that I only got 718 points, I would have expected more. Anyways it is passed so who cares :D Don’t know what to expect from tomorrows test, I hope it is as easy as this one.

(Ubuntu is still my preferred Linux distro… but don’t tell Novell :P sssshhh)

20 Apr 2007

Danish translation of tsclient

Posted by Jacob Emcken Comments (0)

When I came home from work today I read Planet Gnome, I usually visit Planet Gnome several times a day so nothing new in that. But this time I found the post “tsclient 0.150 – call for translators” post by Jonh Wendell.

I thought why not… even tough I always use the English language when ever I can get away with it. I use tsclient a lot at work so I guess it was about time I payed something back to this great program.

I found an old Danish translation back from version 0.106 in the SVN repository, and started from there. I used a Danish translation guide translation guide since this is the first time I’ve ever translated software. This guide linked to a nice word list for Danish translations which helped me a few places where I was unsure about which Danish word I should choose. About 2 hours later I was finished and had submitted the translation in a bug report.

I hope someone will find this useful out there.

29 Mar 2007

Squeezebox

Posted by Jacob Emcken Comments (4)

2 days ago I recieved my Squeezebox… finally I pulled my head out and bought one. I should have done this along time ago. This is one of the best investments since my IBM x40… and that says a lot. At first I got really disappointed because I couldn’t get the Squeezebox to connect to the wireless network. After a few hours tinkering with my wireless access point and the Squeezebox wireless settings I gave up. I plugged it to the network with a wire and installed the latest Slimserver on my Windows partition (I know, I know… Windows, not something I was proud of).

When the Squeezebox found the slimserver on the Windows box the Squeezebox asked me to allow it to update its firmware. After that the wireless ran without problem. Yay.

I’ve started ripping all our music to FLAC even though my girlfriend was almost finished with our over 300 CDs in mp3.

Right now I use Linksys NSLU2 (running Debian Etch) both as music storage and to run the slimserver. It feels a bit slow but it is really not that bad. I’m thinking of finding another NAS but it either has to as silent as the NSLU2 or it has to be wireless. If any of you guys know a good alternative the the NSLU2 let me know.

Back to the Squeezebox… Not only can you play all you digital music but you can listen to internet radio (there is a Pandora plugin). You can have it to wake you up, show RSS (news) feeds on the display, play you podcasts and much more. All you digital music needs gathered in one freaking cool looking, easy to navigate, low noise box in your living room. All in all the Squeezebox rocks! Period.

15 Feb 2007

XSLT: Search replace attribute values

Posted by Jacob Emcken Comments (3)

Yesterday I needed an xsl transformation which could replace a specific attribute value in a xml file and keep the rest intact. The following code is put together by pieces I found around the net (copy-paste FTW :) ):

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:param name="attribute"/>
    <xsl:param name="oldvalue"/>
    <xsl:param name="newvalue"/>

    <xsl:template match="node()|@*">
    <xsl:copy>
        <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
    </xsl:template>

    <!-- This is a generic search replace of attribute values --> 
    <xsl:template match="@*" priority="10">
        <xsl:attribute name="{name()}">
            <xsl:choose>
                <xsl:when test="(name()=$attribute) and (. = $oldvalue)"><xsl:value-of select="$newvalue"/></xsl:when>
                <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
            </xsl:choose>
        </xsl:attribute>
    </xsl:template>
</xsl:stylesheet>

Lets say that the above code is saved in a file called attribute_replace.xslt. Now with xsltproc you would be able to replace the vaule 5011 with 5015 in all attributes called port:

xsltproc --stringparam attribute port --stringparam oldvalue 5011 --stringparam newvalue 5015 attribute_replace.xslt server_config.xml > new_server_config.xml

I used this to manupulate with some JBoss configuration files.