Archive for January, 2010

XMonad on Ubuntu

Sunday, January 17th, 2010

The biggest reason that I wanted to switch to Linux was tiling window managers. OS X is particularly bad at window management. I am constantly dragging this window here, changing the size from a single corner, rearranging my windows, and cursing. All of these actions are tedious, repetitive, slow, and theoretically scriptable. By default tiling window managers never overlap windows, and they provide good keyboard management for window arrangement. Alas they are only really available on X11.

There are many tiling window managers. Off the top of my head there is ratpoison, sawfish, awesome, xwem – written in elisp, stumpwm – written in Common Lisp, and xmonad – written in haskell. I really want to use stumpwm to get a chance to play with common lisp a bit more, but xmonad seems to be a lot more popular. So for now I am using xmonad.

installing xmonad was a simple “sudo apt-get install xmonad”, making it available as a window manager from the gnome-login was more complicated. X11 has a concept of display managers, from what I can tell display managers control your intial login to an x11 system. The standard x11 display manager is xdm, this runs your ~/.xinitrc and ~/.xsession . Most of the information about installing and customizing xmonad recommends editting these files. However under Ubuntu 9.10 gdm (Gnome Display Manager) doesn’t run your ~/.xinitrc . This is very frustrating. gdm does however have a concept of switchable sessions, when you see the login screen for ubuntu, after selecting the user, at the bottom of the screen there will be three drop downs (DRAWING A BLANK), (DRAWING A BLANK) and Session. By default under Session there is Gnome, Gnome-failsafe, and xterm. I ran some apt-get install command (DRAWING A BLANK) that added an option for xmonad to this list, and sure enough upon selecting it, xmonad started on login.

Starting xmonad in this way lets you play with it, but I of course wanted to customize my xmonad preferences. Piecing together from the xmonad faq and some blog posts I came up with this setup, it feels hackish, but it’s a start.

This setup starts nm-applet – the network monitor control thing, this make my laptop automatically connect to my wifi. It also starts emacs, firefox, and rxvt. Then it runs some xmodmap commands to map the key to the right of the right ctrl-key to mod5, my xmonad configuration uses mod5 as it’s hot-key. I will explain my experiences with x11 key mapping in my next post.

There is a directory /usr/share/xsessions/ which contains files that describe the session dropdown box for gdm. In this directory I made a file for xmonad2.desktop

/usr/share/xsessions/xmonad2.desktop

[Desktop Entry]
Encoding=UTF-8
Name=XMonad2
Comment=Leightweight tiling window manager
Exec=xmonad.start
Icon=xmonad.png
Type=XSession

The exec line is the important one, it tells gdm to run xmonad.start. xmonad.start is what I am using instead of a ~/.xinitrc , this is the part that feels very hacky

/usr/local/bin/xmonad.start

#!/bin/bash

xrdb -merge .Xresources

#trayer --edge top --align right --SetDockType true --SetPartialStrut true --expand true --width 15 --height 12 --transparent true --tint 0x000000 &

#gnome-screensaver

#gnome-settings-daemon

#if [ -x /usr/bin/gnome-power-manager ] ; then
#   sleep 1
#   gnome-power-manager
#fi

if [ -x /usr/bin/nm-applet ] ; then
   nm-applet --sm-disable &
fi

#kmix --keepvisibility
emacs &
xterm &
firefox &

#most basic xmodmap stuff
xmodmap -e 'remove Lock = Caps_Lock'
xmodmap -e 'keysym Caps_Lock = Control_L'
xmodmap -e 'add Control = Control_L'
xmodmap -e 'keycode 166 = Hyper_R'
xmodmap -e 'add mod5 = Hyper_R'

#feh --bg-scale /mnt/archivio/foto/2008-2009-dublino/2009-04-10-stefano/hapenny-desktop.jpg &
#exec ~/.xmonadrc
exec xmonad

The last file that I have editted is my xmonad.hs file. This is a haskell file that sets preferences for xmonad. For now all it really does is tell xmonad to use mod5 for it’s hyper-key

~/.xmonad/xmonad.hs

import XMonad

main = xmonad defaultConfig
         { modMask = mod5Mask
         , terminal = "urxvt"
         }

And with that I have a minimally usable xmonad setup. Xmonad’s default hot-key is mod1 which is mapped to alt/meta , an unusable meta key makes emacs useless, thus the change. Many people use the windows key, but I need that for super in emacs, I plan to use the document key for hyper in emacs, thus mod5 for xmonad.

All in all I am enjoying xmonad. I’m not completely familiar with it yet, but it seems incredibly powerful and fast.

My biggest gripe with the X11 graphical environment is the lack of sane keyboard shortcuts. OS X got this very right. CTRL-Q generally quits an app, Apple-Q always quit apps. The biggest thing I miss about OS X though is the input modifiers for text areas. In OS X, the default bindings for almost every text input box are very similar to emacs bindings. Try it. C-w, C-a, C-e, C-p, C-n, C-k all work as expected, if I had put in the time I could have made the meta bindings work too. I know of no equivalent for linux and I miss it. The upside though is, I only really use emacs and firefox, a media player, sometimes a terminal, a chat program, and an irc client. That is a small number of programs to customize, and if I get my act together, I could do chat and irc in emacs too.

Ubuntu and the t500

Sunday, January 17th, 2010

I’m lucky I got the laptop on a Friday, I am spending this whole weekend setting it up to my liking.  It is very nice to be able to take the time to get things right the first time.  This post will detail the hardware and drivers issues that I have dealt with putting ubuntu on the t500.

For the most part everything just worked.  The install was quick and painless – as I have come to expect from ubuntu.  With one exception I didn’t have to do anything at the command line.

The only area where I may have run into trouble was with wireless drivers.  This laptop has an intel 5100 or 5300 wireless card, I’m not sure.  I say may have because I think the problem was really with my router not ubuntu drivers.

My laptop wouldn’t log into my old netgear router when I got it.  The netgear router showed up in the list of networks available, but after entering a password, the network icon just spun and finally failed.  Friends often have trouble logging into this router.  I changed the security on the router to wep from wpa, no luck.  Then I removed all security from the router, no luck.  I tried to login on my MBP, but that didn’t work either.  Finally I put the security on the router back to WPA and my MBP still couldn’t login, the t500 was never able to login to that router.

I bought a new D-Link dual band router.  I had a little trouble initially logging into the N network with the ubuntu and I ran.

sudo modprobe -r iwalgn
sudo modprobe iwalgn

those commands removed and reinstalled the linux wireless kernel module. After that, I was able to log into both networks with ubuntu. I’m not sure if that was a linux problem or a router problem, during the time when I was having trouble logging into the D-Link, my MBP had a little trouble too. Now everything works, and I’m happy.

Graphics worked off the bat. My t500 has switchable graphics, it has an ATI Mobility Radeon 3650 and built in Intel graphics. On vista the os will use the ATI chipset when you want better performance and the intel chipset when you want better battery life, it switches without rebooting, there are no drivers that accomplish this feat on linux, xp, or windows 7.

Next I wanted to test the different driver combinations for performance. I was only interested in 2d performance, so I used the gtkperf benchmark. I was running xmonad with the test window fullscreen when these results were produced.

Intel Drivers

GtkPerf 0.40 - Starting testing: Sat Jan 16 18:51:08 2010

GtkEntry - time:  0.03
GtkComboBox - time:  0.24
GtkComboBoxEntry - time:  0.18
GtkSpinButton - time:  0.05
GtkProgressBar - time:  0.03
GtkToggleButton - time:  0.05
GtkCheckButton - time:  0.02
GtkRadioButton - time:  0.08
GtkTextView - Add text - time:  0.41
GtkTextView - Scroll - time:  0.01
GtkDrawingArea - Lines - time:  1.13
GtkDrawingArea - Circles - time:  1.47
GtkDrawingArea - Text - time:  1.05
GtkDrawingArea - Pixbufs - time:  0.14
 ---
Total time:  4.89

GtkPerf 0.40 - Starting testing: Sat Jan 16 18:51:15 2010

GtkEntry - time:  0.03
GtkComboBox - time:  0.25
GtkComboBoxEntry - time:  0.19
GtkSpinButton - time:  0.05
GtkProgressBar - time:  0.03
GtkToggleButton - time:  0.07
GtkCheckButton - time:  0.04
GtkRadioButton - time:  0.13
GtkTextView - Add text - time:  0.42
GtkTextView - Scroll - time:  0.02
GtkDrawingArea - Lines - time:  1.13
GtkDrawingArea - Circles - time:  1.37
GtkDrawingArea - Text - time:  1.45
GtkDrawingArea - Pixbufs - time:  0.14
 ---
Total time:  5.31

Ati Open Source drivers

GtkPerf 0.40 - Starting testing: Sat Jan 16 18:54:06 2010

GtkEntry - time:  0.02
GtkComboBox - time:  0.30
GtkComboBoxEntry - time:  0.19
GtkSpinButton - time:  0.06
GtkProgressBar - time:  0.05
GtkToggleButton - time:  0.05
GtkCheckButton - time:  0.03
GtkRadioButton - time:  0.05
GtkTextView - Add text - time:  0.38
GtkTextView - Scroll - time:  0.01
GtkDrawingArea - Lines - time:  1.00
GtkDrawingArea - Circles - time:  1.62
GtkDrawingArea - Text - time:  0.95
GtkDrawingArea - Pixbufs - time:  0.07
 ---
Total time:  4.78

GtkPerf 0.40 - Starting testing: Sat Jan 16 18:54:12 2010

GtkEntry - time:  0.03
GtkComboBox - time:  0.29
GtkComboBoxEntry - time:  0.19
GtkSpinButton - time:  0.05
GtkProgressBar - time:  0.04
GtkToggleButton - time:  0.08
GtkCheckButton - time:  0.04
GtkRadioButton - time:  0.08
GtkTextView - Add text - time:  0.41
GtkTextView - Scroll - time:  0.01
GtkDrawingArea - Lines - time:  1.01
GtkDrawingArea - Circles - time:  1.62
GtkDrawingArea - Text - time:  0.95
GtkDrawingArea - Pixbufs - time:  0.07
 ---
Total time:  4.87

Proprietary ATI Drivers

GtkPerf 0.40 - Starting testing: Sat Jan 16 18:59:29 2010

GtkEntry - time:  0.02
GtkComboBox - time:  0.27
GtkComboBoxEntry - time:  0.19
GtkSpinButton - time:  0.03
GtkProgressBar - time:  0.02
GtkToggleButton - time:  0.05
GtkCheckButton - time:  0.02
GtkRadioButton - time:  0.05
GtkTextView - Add text - time:  0.40
GtkTextView - Scroll - time:  0.01
GtkDrawingArea - Lines - time:  0.99
GtkDrawingArea - Circles - time:  1.18
GtkDrawingArea - Text - time: 19.52
GtkDrawingArea - Pixbufs - time:  1.97
 ---
Total time: 24.72

GtkPerf 0.40 - Starting testing: Sat Jan 16 18:59:56 2010

GtkEntry - time:  0.02
GtkComboBox - time:  0.28
GtkComboBoxEntry - time:  0.19
GtkSpinButton - time:  0.03
GtkProgressBar - time:  0.02
GtkToggleButton - time:  0.07
GtkCheckButton - time:  0.03
GtkRadioButton - time:  0.08
GtkTextView - Add text - time:  0.60
GtkTextView - Scroll - time:  0.02
GtkDrawingArea - Lines - time:  1.10
GtkDrawingArea - Circles - time:  1.28
GtkDrawingArea - Text - time: 20.11
GtkDrawingArea - Pixbufs - time:  1.98
 ---
Total time: 25.83

It seemed like the open source ATI driver was a little faster than the Intel driver, but not by a signficant amount. The proprietary ATI driver was atrocious for text. I don’t know that I would notice a difference in day to day use though, when I get a chance, I will run the same tests on my MBP through OS X and virtualized Ubuntu. For now I will be using the Intel drivers. Things will get interesting when my docking station comes in and I start playing with my 30 inch screen.

New laptop — the hardware

Sunday, January 17th, 2010

On Friday my new laptop came in.  I got a Lenovo Thinkpad T500, with 8gb of ram, 3Ghz processor, and 120gb ssd drive — for $1612.  There are great deals at the Lenovo outlet store.

Thoughts

1. Wow is this fast.

  • I can boot, login, and have firefox reload 20 tabs in about 25 seconds.
  • I can run “find / | wc -l” in .5 seconds
  • Netbeans and eclipse start in 2 seconds

I attribute the speed to the ssd.  Linux helps some, but the ssd makes all the difference.  If you use a computer more than an hour a day, go out and buy an SSD now.  The speed is absolutely incredible

2. I like the build quality.   The screen doesn’t flex at all like my 2nd gen MBP pro did (first gen case).   I’ll see how it holds up.

3. The keyboard is awesome, except for the flex under the s,d,f,w,e,r,x,c keys.  When I press those keys, I can feel the key activation, than I hear a thump as the keyboard back hits another part of the case.  I will talk to Lenovo about this, I might be able to fix it with shims.  This has been discussed extensively http://www.thinkpadtoday.com/thinkpad-t400-and-t500-keyboard-stiffness-myth-busted.htm .

4. I don’t like the trackpad nearly as much as I did on the MBP.   Two finger scrolling on the MBP was awesome.   On this machine I have to use the right side of the trackpad for vertical scrolling.  This isn’t a huge deal, I am working very hard to set up my environment so that I don’t have to manipulate the pointer at all.  On the plus side, the trackpad buttons feel much better than the button on the MBP, that button was so wide that when I would slap one side of it with my thumb, sometimes it wouldn’t register, others it would twist down on that side instead of moving down in a straight path.

For the most part hardware is hardware.   Running linux on this machine is much more interesting, I’ll talk about that next