Monday, March 22, 2010

Nerd Food: Lucid, the Lynx

Well, its that time of the year again. Unwisely, I always take the Ubuntu releases when the first betas are out, I just can't resist the urge. Not on all boxen, mind you. I always pick a victi^W candidate box to do the testing, give it a spin for a week or two and then proceed to upgrade the whole stable when I feel confident enough. It has been that way since Warty, and Lucid was no exception. However, Lucid has been exceptional in pretty much every other regard - mainly for positive reasons, but for some negative ones too. Let's retrace my steps back to the weekend, for the full Lucid experience.

In the many years I've burned ISO images I can't recall ever having had problems with dodgy media. I remember back in the RedHat 5 days when I used to religiously test the media before installing. At some point or other, having never found any defects, I gave up on that; luck has been on my side ever since. Ever since, that is, until this weekend, when the 1 GBP CD I had bought from a local camera shop - out of desperation - proved to be dodgy. After trying to install Lucid a couple of times and failing miserably with weird errors, I thought perhaps the issue was the CD. But on reboot, lo and behold: the option to test the media had been removed! I'm pretty sure it was around in Karmic, so this is a Lucid "innovation". I guess for basic users this is not that bad, but old hands will feel slightly disappointed. Back to the shops I went - this time buying six CDs for good measure. (where did I put that blasted USB key!!). This time round the installation went OK - no major innovations from Karmic, just a general sense of polish.

After installation, I was greeted with the most well thought out boot I've seen in Linux. Now, let me qualify that: I haven't used any other distro since Warty, so I don't really know what other people are up to. It is likely all distros boot this way these days - and indeed I think a lot of the glory comes from plymouth, a RedHat technology. But let me tell you the way I saw it. The boot is almost seamless; KMS, plymouth and GDM work together to provide this amazing flow from boot to usable desktop; once KMS does the mode setting there is no more dodgy flickering, blinking cursors, intro music out of sync and so many other little annoyances of the past. Its just... elegant. And the whole process takes around 40 seconds (depending how fast you can type your password, of course).

The second thing I noticed - and I'm still not quite believing myself - is the amazing, and I mean AMAZING, memory usage. I thought that there was a bug in the System Monitor applet, because the dark green colour that indicates the memory usage was so low I could not see it. This is a bit less impressive than it sounds, as this particular machine has 4 GB of RAM, so one cannot rely on percentages. But the figures reported by other tools didn't lie: less than 200 megs taken by a fully usable gnome session with no applications running. I then proceeded to install all my usual apps just to see how a reasonable session would look like. The session I'm running at the moment has the following desktop applications:
  • skype
  • empathy for messaging (facebook, MSN, google)
  • Google Chrome (8 tabs)
  • Evolution for email
  • Liferea for RSS feeds
  • Emacs for development
  • Dia for diagrams
  • Assorted PDF documents with Evince
  • OpenOffice Writer for word processing
  • Nautilus doing large file copying (restoring backups)
  • Gimp editing a couple of images
According to the System Monitor, it is costing me less than 700 megs. CPU usage is extremely low - but remember this is a 4-core system. Compared to Karmic, this is nothing short of amazing.

System Monitor Applet and Workspace Viewer with all open applications. Dark Green is used memory.

I'm still playing around with the apps, so I can't really say much about them. I have noticed a lot of crashes being reported, especially from plymouthd, tracker, etc.

Unfortunately, not everything was positive with this first experience. Having an NVidia card, the first thing I tend to do is to enable binary drivers - purely so I can use compiz. I don't really need them for anything else, but there are a couple of things that compiz provides that are so interlinked with my workflow that I struggle to function without it. In the past, NVidia drivers have worked really well, with minimal fuss. I've relied on the distro supplied ones for a while, without any problems. I regret to say, this has changed with lucid and for the worse. So much so that I know believe binary drivers are just plain harmful.

Having installed NVidia drivers I rebooted and lost X altogether. The reason why became apparent after a few hours of investigation - and it is amazing the speed at which bug reports are replied to in Ubuntu. But after applying the workaround, even though I got X back the entire smoothness experience had been lost! This is because the KMS integration is amazingly _bad_ when using binary drivers, and this is obviously not the fault of the community. It just sucks, its hard to describe. Not just that, but on my second boot, my box just HUNG! It didn't do that afterwards, but its shocking to think that with the "unstable" nouveau the experience was smooth and stable and with the binary drivers I managed to crash the box in minutes.

But NVidia wasn't done with me just yet. For the moment I need to access this box from my karmic laptop via XDMCP, a process that has been made considerably harder of late. Not a problem; nothing a xinit with a manual ssh -X cannot solve. And then I'm greeted with a totally inverted screen. And I mean totally, it was like left-to-write rotation with up-to-down or something. After much head scratching, I found out this was yet another NVidia feature. That was it, removed all traces of these nasty binary drivers and defaulted back to nouveau.

Don't take me wrong. I think its great that NVidia care about Linux and provide us with drivers. After all, they don't have to. But, from purely an egotistical perspective, I think open source, in-kernel drivers are the future. I just want something that works out of the box and is integrated into the kernel release cycle. I don't want to wait to have proper KMS support. I don't want to have to do crazy workarounds to get proper plymouth support. And I don't want weird bugs. My experiences with the Intel drivers have been absolutely positive. And now nouveau seems to be on the right track.

Anyway, those were the key problems, but there were other issues I haven't quite finished investigating:
  • pulseaudio is behaving weirdly. It seems that if I login locally and then log in remotely the sound comes out of the server's sound card - which is an acceptable behaviour for me; however, if I don't log in locally to the server, then I get no sound at all, locally or remotely. This is not so ideal.
  • Wireless is not quite working for my server network card (Broadcom BCM4318). The binary drivers are enabled and all but for some reason it fails to connect (time out). This is not too bad as the server is wired into the modem.
In addition to this, I ended up having to wire my laptop to the modem as I was finding XDMCP over wireless to be utterly unusable. The delays were akin to running a VM, seconds some times - and chrome was particularly affected by this. Using a 100-MBit cable the experience is identical to working locally. Now if only I could suspend/resume my sessions!

All and all I must say I'm really happy with Lucid, and if nouveau could do acceleration (or if I had an Intel card) I would have cried with joy on first boot.

UPDATE: One very, very important thing I forgot to mention are the silly little annoying UI changes (thanks sardaukar, your post reminded me of this!). Truth is, I ended up spending _a lot_ of time figuring out how to revert some of the new "features" such as button ordering, etc. I didn't really give them a fair trial - but my reasoning is, I'm happy with my current workflow and I can't see a need to change it. When gnome shell comes I'll re-evaluate it.

Here's a list of the things I've done til now as a script. I'll try to keep it updated.

#!/bin/bash

# do not display text next to icons on toolbars. Interface
# tab of appearance has been removed
# so you can't do this from the GUI any more.
gconftool --set /desktop/gnome/interface/toolbar_style --type string icons

# display icons in menus. they look a tad bare without them.
gconftool --set /desktop/gnome/interface/menus_have_icons --type bool true

# display icons in buttons
gconftool --set /desktop/gnome/interface/buttons_have_icons --type bool true

# fix the crazy new button placement and order.
# not sure why gconftool-2.
# (note: this is one single long line)
gconftool-2 --set /apps/metacity/general/button_layout --type=string :minimize,maximize,close

# check for updates as they come available
gconftool --set /apps/update-notifier/regular_auto_launch_interval --type int 0

Thursday, March 18, 2010

Nerd Food: Getting ls to behave

ls appears to be sorting rather weirdly of late (well, since quite a few Ubuntu releases), ignoring upper and lower case, e.g.:

drwxr-xr-x 2 marco marco 4096 2010-03-17 00:12 cmake
-rw-r--r-- 1 marco marco 8708 2010-03-17 18:39 CMakeLists.txt
drwxr-xr-x 2 marco marco 4096 2010-03-17 15:17 config
drwxr-xr-x 4 marco marco 4096 2010-03-11 18:22 cpp
drwxr-xr-x 2 marco marco 4096 2010-03-17 16:24 doc
drwxr-xr-x 2 marco marco 4096 2010-03-12 01:39 glade
drwxr-xr-x 5 marco marco 4096 2010-03-17 18:42 output
-rw-r--r-- 1 marco marco 1124 2010-03-17 16:26 README.TXT
drwxr-xr-x 2 marco marco 4096 2010-03-11 18:22 scripts
drwxr-xr-x 3 marco marco 4096 2010-03-11 18:22 sql
drwxr-xr-x 3 marco marco 4096 2010-03-11 18:22 templates

This is utterly annoying. The main reason people use upper case filenames is precisely because they come up at the top of the listing. It appears the reason why is the locale, more precisely LC_COLLATE.

$ locale | grep LC_COLLATE
LC_COLLATE="en_GB.UTF-8"

By changing it to C, it all behaves as expected:

$ export LC_COLLATE=C
$ ls
-rw-r--r-- 1 marco marco 8708 2010-03-17 18:39 CMakeLists.txt
-rw-r--r-- 1 marco marco 1124 2010-03-17 16:26 README.TXT
drwxr-xr-x 2 marco marco 4096 2010-03-17 00:12 cmake
drwxr-xr-x 2 marco marco 4096 2010-03-17 15:17 config
drwxr-xr-x 4 marco marco 4096 2010-03-11 18:22 cpp
drwxr-xr-x 2 marco marco 4096 2010-03-17 16:24 doc
drwxr-xr-x 2 marco marco 4096 2010-03-12 01:39 glade
drwxr-xr-x 5 marco marco 4096 2010-03-17 18:42 output
drwxr-xr-x 2 marco marco 4096 2010-03-11 18:22 scripts
drwxr-xr-x 3 marco marco 4096 2010-03-11 18:22 sql
drwxr-xr-x 3 marco marco 4096 2010-03-11 18:22 templates

Much better! To make it permanent, add it to your .bashrc.

Wednesday, March 17, 2010

Kids Thrive on Complexity

I've found a probability distribution that went unstudied until now, and the random process originating it is my nephew. To be more precise, its the dazzingly complex algorithm he uses to distribute the contents of a packet of crisps across a room - in his lingo: eating. Its not just the quasi-uniform floor coverage (including underneath all furniture), the fact that no two crumbs share the same size, or even its speed that makes it unique; its the efficient use of resources. A single room can be covered with _the remains_ of a small packet of crisps. Amazing.

Thursday, March 11, 2010

Nerd Food: use_action_appearance saga

While playing with Ian Remmel's instructions on how to use Gtk::Action and Gtk::ActionGroups, I've bumped into an annoying problem: for some reason my toolbar icons and menu items started behaving weirdly after adding some Gtk::Actions to them. Symptoms were blank labels on menu options and blank toolbar items, or toolbar items with words rather than stock items. After some head scratching, I think I got to the bottom of it. Basically, the toolbar or menu item is taking its caption from the Gtk::Action.


Stock item refresh not being displayed.

What is puzzling is that the Glade UI clearly says that "Use Action Appearance" is set to "No". However, close inspection of the .glade file shows no mention of this property at all, so somehow the default value for it appears to be "Yes". I proved it by manually hacking use_action_appearance, e.g.:

<property name="related_action">act_reload</property>
<property name="use_action_appearance">False</property>

This fixed all my prolems. Of course, this is not a long term solution because it gets overwritten every time you save your .glade file. A more enduring workaround may be to do this in code, possibly where you add the Gtk::Action to the Gtk::ActionGroup, at least until Glade fixes the bug.

Another puzzling aspect of this bug is that there has been a lot of work around it of late, as the release notes of glade-3 3.6.7-0ubuntu1 imply:

- Sync up remaining properties at load time (fixes use-action-appearance property and any other unmentioned property states at load time, also unvails broken orientation default value in GTK+, bug 587256).
- Fixed glitches with use-action-appearance at save time.

A quick apt-cache check reveals we're running the correct version:

$ apt-cache show glade | grep "^Version"
Version: 3.6.7-1ubuntu1

So either all of this activity around use_action_appearance did not fix the bug or there was some kind of merge mistake downstream. Here we can see the commit that tried to fix the problem - nothing obvious to the layman, unfortunately. By downloading the tarball used to make the Ubuntu package, we can easily confirm that the upstream commit is present downstream.

An upstream bug report had been filled for this problem: #582882. Shame it wasn't cross referenced in the release notes, like some others were. Perhaps the maintainers haven't gotten to the bug report just yet.

Nothing more to do other than wait for the glade maintainers...

Update: Another workaround for this problem is to set the icon / lable text directly on the action.

Monday, March 01, 2010

Nerd Food: Suspend and Resume on Karmic

For some reason, the suspend and resume in Karmic (Ubuntu 9.10) fails to restart wireless properly on one of my laptops. According to lspci the card is a RealTek RTL8101E/RTL8102E . Everything else works ok, and the failure is intermittent - maybe one resume fails out of three or so. If you have the same problem, you can try the following before restarting your machine:

$ su
# cd /etc/init.d
# ./networking restart
# ./network-manager restart

This seems to sort the problem out, most of the time. Hopefully the Lynx is going to fix this.