Skip to Content »

Tech Life of Recht » archive for October, 2007

 Remote control with MacBook Pro and Ubuntu

  • October 28th, 2007
  • 5:44 pm

I managed to get the remote control to work with my MacBook Pro and Ubuntu. It should work out of the box according to almost everybody when you google for it, but it just didn't. I know, I said ealier that I didn't know what to use it for, but that doesn't really matter. What matters is that I had a piece of hardware which didn't work, and that's just not good enough.
After digging around a little in lsusb and the module source code, I found out that on the most recent MacBooks, the IR receiver has been assigned a new device id. The original receivers had id 0x8240 while mine has 0x8242. It doesn't look like anything else has changed, and after recompiling the module with the correct device it, it suddenly worked like it should.

Compiling the module isn't exactly for the faint of heart, so I won't describe the details here - let me know if you want it, and I'll post it. However, it does include "apt-get source linux-ubuntu-modules-2.6.22-14-generic".

Also, remember that the appleir module must be loaded before usbhid. To do this on a running system do
"rmmod appleir usbhid; modprobe appleir; modprobe udbhid"
Remember to do it on one line, or you will lose keyboard input after running rmmod.

Other than this, follow this guide to configure the remote control. So far, my .lircrc contains the following, supporting slide change in OOImpress and Amarok:

CODE:
  1. begin
  2.         prog = irxevent
  3.         button = KEY_MENU
  4.         button = KEY_PP
  5.         config = Key space amarokapp
  6.         flags = quit
  7. end
  8. begin
  9.         prog = irxevent
  10.         button = KEY_MENU
  11.         button = KEY_N
  12.         config = Key ctrl-alt-b amarokapp
  13.         flags = quit
  14. end
  15.  
  16. begin
  17.         prog = irxevent
  18.         button = KEY_MENU
  19.         button = KEY_MENU
  20.         config = Key Escape CurrentWindow
  21. end
  22.  
  23.  
  24. begin
  25.         prog = irxevent
  26.         button = KEY_P
  27.         config = Key Page_Up CurrentWindow
  28. end
  29. begin
  30.         prog = irxevent
  31.         button = KEY_N
  32.         config = Key Page_Down CurrentWindow
  33. end

Btw, I've filed a bug with Ubuntu, so hopefully the module will be fixed at some point.

 Suspend success

  • October 27th, 2007
  • 12:37 am

as I wrote about yesterday, I had some problems getting software suspend to work with Ubuntu and my MacBook Pro. Well, it looks like the problem has been solved. As reported here, it looks like there's a bug in the kernel, so downgrading a little should fix it. However, in my case I also had to disable gnome-power-manager - not really an issue. After changing these two things, I've been able to suspend and resume without problems - at least for now.

 My xmonad start script

  • October 25th, 2007
  • 10:54 pm

After reinstalling xmonad on my laptop using Ubuntu as the base distribution, I've finally got a setup I like, so I thought I'd share it. So, here is my script which starts xmonad:

CODE:
  1. ssh-add ~/.ssh/id_dsa </dev/null>/dev/null
  2.  
  3. Esetroot /usr/share/backgrounds/warty-final-ubuntu.png
  4. unclutter -idle 2 &
  5.  
  6. urxvtd -f -o
  7.  
  8. gnome-settings-daemon &
  9. gnome-power-manager
  10. gnome-volume-manager &
  11.  
  12. BG=white
  13. FG=black
  14. FONT="-xos4-terminus-medium-r-normal--12-120-72-72-c-60-iso8859-1"
  15.  
  16. export PATH=$PATH:`dirname $0`
  17.  
  18. # create a pipe for xmonad to talk to
  19. PIPE=$HOME/.xmonad-status
  20. rm -f $PIPE
  21. mkfifo -m 600 $PIPE
  22. [ -p $PIPE ] || exit
  23.  
  24. # and a workspace status bar, reading's xmonad's stdout
  25. dzen2 -e '' -w 680 -ta l -fg $FG -bg $BG -fn $FONT -h 15 <$PIPE &
  26.  
  27. `dirname $0`/status &
  28.  
  29. xmonad> $PIPE &
  30. wait $!
  31.  
  32. pkill -HUP dzen2
  33.  
  34. wait

This script is launched from ~/.xsession. It uses dzen and some of the dzen gadgets (which must be compiled separately from dzen/gadgets). It also starts some of the Gnome daemons which normally run under Ubuntu. This means that power management and sound volume goes through Gnome, and devices are mounted automatically when they are added to the system.

Two dzens are launched: One for displaying workspaces and one for general status. The general status script looks like this:

CODE:
  1. #!/bin/sh
  2.  
  3. BG=white
  4. FG=black
  5. FONT="-xos4-terminus-medium-r-normal--12-120-72-72-c-60-iso8859-1"
  6.  
  7. while :; do
  8. MEM=`awk '/MemTotal/ {t=$2}; /MemFree/ {f=$2}; END {print t-f " " t}' \
  9.   /proc/meminfo | dbar -s ':' -l 'Mem:' -w 10`
  10. CF0=$(echo `cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq` \
  11.   `cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq` | dbar -w 7 -l 'CPU0:')
  12. CF1=$(echo `cat /sys/devices/system/cpu/cpu1/cpufreq/scaling_cur_freq` \
  13.   `cat /sys/devices/system/cpu/cpu1/cpufreq/scaling_max_freq` | dbar -w 7 -l 'CPU1:')
  14. DATE=`date +"%d-%m %k:%M"`
  15.  
  16. REM=`grep 'remaining capacity' /proc/acpi/battery/BAT0/state | awk '{print $3}'`
  17. LAST=`grep 'last full' /proc/acpi/battery/BAT0/info |awk '{print $4}'`
  18. STATE=`awk '{print $2}' /proc/acpi/ac_adapter/ADP1/state`
  19. if [ "$STATE" = "on-line" ]; then
  20.   BAT=$(echo $REM $LAST | awk '{printf "Bat: %.1f%%, AC", ($1/$2)*100'})
  21. else
  22.   PRESENT=`grep 'present rate' /proc/acpi/battery/BAT0/state | awk '{print $3}'`
  23.   BAT=$(echo $REM $LAST $PRESENT | awk '{printf "Bat: %.1f%%, %d min", ($1/$2)*100, ($1/$3)*60}')
  24. fi
  25.  
  26. LOAD=`awk '{print $1 " " $2 " " $3}' /proc/loadavg`
  27.  
  28. echo "$CF0 $CF1 $MEM | $DATE | $BAT | $LOAD"
  29. sleep 5
  30. done | dzen2 -e '' -x 440 -w 1000 -fg $FG -bg $BG -fn $FONT -h 15

The script is made for a MacBook Pro with a two core processor and acpi. It displays the CPU frequencies in a dbar, memory usage, battery status, and load. I would like to display network status too, but I can't figure out how to dig around in dbus efficiently, so that's still missing.

 MacBook Pro

  • October 24th, 2007
  • 11:04 pm

Last week, we had some of the local drugheads come into the office at night, and they ran off with my laptop, and 6 other laptops. I had a trusty Lenovo Thinkpad z61m with Ubuntu (and xmonad, of course), which is now gone, together with whatever I had on it. Naturally, I didn't have backup of everything, but at least all of my code was checked into Subversion, so the most critical I'm missing now are some course material.
Luckily, it didn't take long before we got permission to go out and buy some new laptops (this is one of the great things when you're working for a small company: no company procedures which have to be followed). We were told that we should probably go for a IBM, HP or Apple laptop. Now, I don't know about you, but when I buy new hardware, I can't just decide. It takes a couple of days (or even weeks), so deciding what to buy and live with for the next couple of years in half an hour certainly wasn't easy. In the end, I got a MacBook Pro with a 15" display - but only after confirming that it could run Linux, in case OS X got on my nerves too much.
Having lived with xmonad for a couple of months, it didn't take long before I decided that OS X might be pretty nice, but there's just too much focus on the looks, so I installed rEFIt, downloaded the new Ubuntu 7.10 and installed it.

I had anticipated some problems installing, as some of the experience reports on the net indicated that some things might go wrong, but that didn't really happen. Everything just installed (tm) - almost: The wireless driver had to be compiled from Subversion. Other than that, everything works: X, accellerated graphics, Xinerama/TwinView, sound, webcam, temp. sensors, keyboard lights, and touchpad with different zones. Only two things aren't working: The remote control and suspend to ram.
I can live without the remote control (actually, I can't really imagine what I should use it for if it worked), but the missing software suspend is not exactly optimal. It doesn't help that it's not consistent: Sometimes it can actually suspend and resume correctly. Using 'pm-suspend --quirk-post-vbe' seems to increase the number of times it works.
At other times, it doesn't suspend. Sometimes, it just blanks the screen, and nothing else happend. It can also switch to console with a blinking cursor, and then nothing else happend. Sometimes bliking the cursor is so hard it has to turn on the fans. No matter what, a cold boot is the only way forward.
If it manages to suspend, resume often fails. When this happens, the disk turns on, but the screen doesn't, and there's no response to any keypresses. Again, cold boot is the way forward.
I haven't managed to identify why software suspend doesn't work. The only hint I have is that if the network cable is unplugged when I suspend, it seems to suspend successfully more often than else. Acpid should unload the network drivers before suspend, so I can't see why this has anything to do with it. I'm hoping a kernel upgrade will fix it at some point.

 Hudson plugin 1.0.3

  • October 16th, 2007
  • 11:50 pm

Version 1.0.3 of the Hudson plugin for Eclipse is out. New features:

  • Read proxy settings from the Eclipse configuration
  • Support self-signed certificates
  • Store icons in ImageRegistry to avoid leaks

Enjoy.

 SmugMug uploader

  • October 3rd, 2007
  • 12:10 am

Some time ago I bought an account with SmugMug for my pictures. SmugMug is pretty nice, and has more or less the features I need.
I quickly ran into a problem with uploading a lot of pictures. There are different tools for it, but nothing which really fit my needs: Execute a script with a list of files as arguments, print a list of available albums, enter the correct album, and upload the images (with a progress meter).
Luckily, there's the SmugMug API, which is a nice REST interface, and it didn't take long to hack a shell-script together using curl and the other usual suspects like grep and sed. I've now polished the script a little so it does some error handling, so now it's available here as smugup.sh. It requires curl, sed and grep, probably in the GNU versions.

Username and password can be set as arguments with -u and -p, but they can also be set in ~/.smugup like this:

CODE:
  1. EMAIL="recht@somewhere"
  2. PASSWORD="passhere"

The script is used by simply giving the pictures to be uploaded as argument to the command:

CODE:
  1. smugup.sh /data/pictures/*.jpg

The script will then print a list of available albums and expect the selected album ID as input, and then it will begin uploading.

 Hudson plugin for Eclipse 1.0.2

  • October 2nd, 2007
  • 10:21 pm

I've just released a new version of the Hudson plugin for Eclipse. This version fixes the somewhat confusing default setting, where all build types were filtered out. Now, all projects should be listed by default.
I've also added an ignore option to each project. By right-clicking on a project, it's possible to ignore build errors. This will make the status icon at the bottom of the window green even if there is a build error in a project. This is useful when there are several projects, but you only work on some of them yourself.
The new version can be installed using the update site, or it can be downloaded from http://code.google.com/p/hudson-eclipse.

 The xmonad experience

  • October 1st, 2007
  • 6:28 pm

I've been running xmonad on both my desktop computer at home and my laptop at work, and overall I'm pretty happy about it. However, I've had to work around some stuff:

  • There's no fancy graphical tools like the default Ubuntu desktop. This means no network-manager, no battery monitor, and so on. For the network manager (nm-applet), I've used knetworkmanager - almost the same, but it works a little better. I usually just run knetworkmanager, connects to the right network, and closes it again.
  • Battery is monitored through dzen
  • For mounting and unmounting devices, something that Ubuntu did automatically, I use pmount directly.
  • I use mplayer through kplayer, a KDE mplayer wrapper, which makes it possible to run movies in a large window with the ratio preserved, something I've not been able to with the command line directly.

Other than that, there's not much to it. It does attract some interest, though. Today, I held a course on Java and Web services, and someone asked me what type of Linux I ran. Not regarding the wrongness of the question, I answered "xmonad" - and there was 5 seconds silence, followed by a vague "ah...".