Pondering the mystery…

Foo Fighters Wembley Concert, the tale of a weekend like no other

November 19th, 2008 cmsj

It seems like I have failed utterly to comment on the towering totem of raw awesome that was the Foo Fighters concert on a balmy Saturday in June.

To put the event in context, I spent a few hours during the day with Rike, Alex and Simon in Hyde Park at the Red Bull Flügtag. We ate, we drank, we watched ridiculous people flinging themselves from a raised platform into The Serpentine in craft that almost invariably were capable solely of an ungraceful and undignified plunge. The notable exception being a poor attempt at a basic hangglider design, which somehow stalled and dived its way to a distance record.

We then said goodbye to Alex and headed half way across London toWembley Stadium, where we arrived to a bigger queue for the toilet than for the gates, so we were inside in a jiffy. We’d missed the support acts nonsense and things were gearing up for the Foos. It was a pretty impressive sight and sound to walk out onto what would normally be the pitch, amongst an almost capacity crowd (Dave Grohl seemed to think there were 86,000 people there).

Then noise, then cheering, then rock. Twenty minutes of rock go by before they take so much as a beat of a break to say hello. More rocking. Rock. Rockity rock. Rock. Special appearance by Jimmy Paige and John Paul Jones from Led Zepplin. Rock. Good night. Massive firework show.
Best gig I’ve ever been to, and I’m not expecting it to ever be beaten.
I would describe the show in more detail, but if you weren’t there then you lose, sorry.

Except you don’t lose! You can now buy a DVD or a Bluray of the show, and I am here to tell you that you absolutely should, especially if you own a Bluray player.

My copy of the Bluray arrived yesterday and I’ve watched the entire 2 hour show twice so far. There seem to be cameras everywhere and they’re edited together well, so it’s a treat to watch. The show was presented in conjunction with BBC Radio One and they broadcast it, so the sound recording is very good. What else do you care about? There are no extras, but who cares.

As if the weekend hadn’t offered up enough excitement already, Simon and I went to Silverstone on the Sunday to see a day of Renault motorsport.

Using inotify in a pygtk application without pyinotify

October 24th, 2008 cmsj

I am lazy. There’s no denying it, it’s simple fact.

That means, for example, when I am working with pygtk and I look at the API for pynotify, I am sad, because it’s a polling API and I hate polling.

What I like is GTK’s event model. I like telling it what to run when things happen and letting it take care of all the pain for me. Obviously it’s possible to write some code which will do the polling and then trigger an event, but that compromises my freedom to be lazy.

Step in pygobject, which contains the bindings for GIO. Within the bowels of this beastie are the required components to monitor a file for changes in a very few lines of python:

#!/usr/bin/python
import gtk
import gio

def file_changed (monitor, file, unknown, event):
  if event == gio.FILE_MONITOR_EVENT_CHANGES_DONE_HINT:
    print "file finished changing"

file = gio.File('/path/to/some/file')
monitor = file.monitor_file ()
monitor.connect ("changed", file_changed)
gtk.main()

That’s it. I don’t know what the “unknown” argument for the callback is, probably the optional user_data connect() argument and this is but a small part of what inotify/GIO can do, but if you just care about being told when a file is updated, it’ll do (with caveats that you can never really know when a file has finished being changed, so be careful to validate it before you trust its contents).

Ubuntu 8.10 (Intrepid) power performance

October 9th, 2008 cmsj

In one word: wow.

Out of sheer curiosity last night I fired up the excellent powertop and decided to see how my system was doing. It was producing a couple of hundred fewer interrupts per second than it did in 8.04 (Hardy), and was using 1-2Watts less power.

Previously I have always resisted applying tweaks to my laptop that would attempt to reduce power, but since things were improving, the temptation was simply too great and I started digging out all the resources on this (by far the most useful being the tips on Intel’s grammatically horrific http://www.lesswatts.org/). I had two reasons for not doing this previously - firstly I didn’t want to deviate too much from a default install of Ubuntu (if only because it makes it much harder to reproduce bugs), but secondly I kept running into little weirdnesses. The most inconvenient of these was enabling AHCI link power management (which basically puts the hard disk bus to sleep when there is no IO); Enabling this and then suspending the laptop produced a 5 second delay on resuming because the kernel was forgetting it had put the bus to sleep and so had to wait for it to time out and be reset.

This particular niggle is fixed in 2.6.27 and so my 3-4 second resume times are preserved and I can save power! \o/

After a little while tweaking disk, AHCI, USB, filesystem, wireless, sound and ethernet options I ended up with a system which runs between 8 and 9 Watts when idle, down from 10-14 Watts, which I think is a pretty impressive saving and I’m very curious to find out from other Thinkpad X300 owners how well Windows performs in the power usage stakes - we always hear that Linux is a bit worse, but I’d be really quite surprised if the machine can run with very much less - it’s spending (when idle, obviously) 99% of its time in the deepest processor sleep state and is only generating about a hundred interrupts per second (about 70-80% of which are due to my using a 3D desktop and wireless).

openssh 5.1 chrootdirectory permissions issue

October 9th, 2008 cmsj

If you’re playing with the excellent new ChrootDirectory and internal-sftp options in recent OpenSSH releases (such as 5.1 which is in Ubuntu 8.10 Intrepid), you may have hit an error like:

fatal: bad ownership or modes for chroot directory

You may also have searched on Google for what to do about it and come away with very little useful information.

Well no more! I did the same thing and got bored of reading mailing list posts, so read the source code instead. The relevant section is in session.c:

    if (stat(component, &st) != 0)
      fatal("%s: stat(\"%s\"): %s", __func__,
          component, strerror(errno));
    if (st.st_uid != 0 || (st.st_mode & 022) != 0)
      fatal("bad ownership or modes for chroot "
          "directory %s\"%s\"",
          cp == NULL ? "" : "component ", component);

This is quite simple really, it’s stat()ing the directory specified for “ChrootDirectory” and all its parents up to / and checking that they are:

  • owned by root
  • not group or other writable
  • (it also checks they are actually directories, but I’m going to assume you’re not stupid enough to try and chroot into a file ;)

Note my emphesis that these checks apply to the chroot directory itself and its parents and /, so if you are chrooting users into /srv/chroot/ then you need to ensure that /, /srv and /srv/chroot are owned by root and not writable by the group (even if it’s root, bizarrely) or other users.

Sorted.

Quick guide to saving power with USB devices

October 9th, 2008 cmsj

I have a laptop with some USB stuff built in. Some devices (such as Bluetooth) can be made to entirely disappear from the USB bus, however, the fingerprint reader and webcam can’t, but they sit on the USB bus and draw power.

Fortunately the USB specs allow devices to be put to sleep if they’re not being used and support that feature. Unfortunately many devices advertise they support it when they really don’t, so Linux is unable to automatically put every USB device to sleep.
Fortunately you can control the setting by hand, and this is how. Firstly, start off with a Terminal and run the command “lsusb”:

cmsj@kodachi:~$ lsusb
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 002: ID 0483:2016 SGS Thomson Microelectronics Fingerprint Reader
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 002: ID 17ef:4807 Lenovo
Bus 004 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
cmsj@kodachi:~$

You can ignore the “root hub” entries, the interesting two are “SGS Thomson Microelectronics Fingerprint Reader” (guess which device that is ;), and “Lenovo” (this is the webcam).

So now we need to poke at those devices to enable their autosleeping. If we look at the entry for the webcam:

Bus 004 Device 002: ID 17ef:4807 Lenovo

I’ve highlighted “4807“. This is the Product value for this USB device (if you’re curious, the “17ef” part is the Vendor value and uniquely identifies the maker of this device).

Now we need to find out where abouts the webcam lives in the /sys/ filesystem (which is something the kernel provides to give applications lots of information about the hardware in your system).

The following command will put us on the right path:

grep 4807 /sys/devices/*/*/usb*/*/idProduct

Which, on my laptop, returns:

/sys/devices/pci0000:00/0000:00:1d.7/usb4/4-5/idProduct:4807

Take that information you get, and chop the “idProduct:4807” bit off the end, just leaving “/sys/devices/pci0000:00/0000:00:1d.7/usb4/4-5/” (yours will look a little different to this) and add “power/level” to the end.

You should now have something that looks pretty much like “/sys/devices/pci0000:00/0000:00:1d.7/usb4/4-5/power/level” and if you get the current setting:

cmsj@kodachi:~/Desktop$ cat /sys/devices/pci0000:00/0000:00:1d.7/usb4/4-5/power/level
on
cmsj@kodachi:~/Desktop$

you can see it is “on”, which means it will not be automatically put to sleep. To change that, run:

echo "auto" | sudo tee /sys/devices/pci0000:00/0000:00:1d.7/usb4/4-5/power/level

and test if your device still works (so if it’s a webcam, fire up “cheese“, or if it’s a fingerprint scanner that you use, test if it still accepts your finger). If everything is good then you can put something in /etc/rc.local so the power saving will be set up every time you reboot your computer:

echo "auto" > /sys/devices/pci0000:00/0000:00:1d.7/usb4/4-5/power/level

and that’s it! Repeat this for all the USB devices in your laptop and enjoy the power saving (run “powertop” about 10 minutes before you start doing this so it has time to get a good average of your power usage, then see how much difference this makes. It could be up to 0.5Watts per device). Note that this won’t work particularly well for external USB devices you plug in, becuase the /sys/ path won’t exist until you plug the device in, so you’d need to do the above steps every time you connect it.

Hopefully HAL will start whitelisting devices which can be suspended, but I don’t know of any work in this direction at the moment.

Terminator 0.11 released!

September 21st, 2008 cmsj

Head over to the Terminator Homepage to get the goodness that is version 0.11. Mostly just bugfixes this time, for things which hurt 0.10 users. Also present is support for X Session Management, although until we have proper profiling support, this is of limited use.

The source tarball is up, of course, and the Hardy/Intrepid PPAs should have packages by the time you read this.

Script for funky SSH titles in GNU Screen

September 18th, 2008 cmsj

I just uploaded a script that I’ve been using and refining for some while, with help from a variety of people too numerous to mention.
Basically the deal is that when you ssh somewhere from inside a GNU Screen session, the screen’s title is set to the hostname you ssh’d to. Simple.

The page for the script is here

Terminator 0.10 released

August 28th, 2008 cmsj

It’s been a week or so shy of two months since we pushed 0.9 out of the door and originally we planned on following up with a 0.9.1 release shortly after to clear up some bugs, but for a variety of not particularly good reasons this never happened.

Instead we’ve got a new release for you… 0.10.

It doesn’t have any shiny whizz-bang features like 0.9 had, but it does bring a bunch of bug fixes and the groundwork necessary for our 1.0 release.

As usual, head over to the homepage, or Launchpad to get the goodness.

Software fail

August 1st, 2008 cmsj

Update: It has been suggested that it is not productive or collaborative to talk negatively about some developers releasing software for unixy operating systems without really trying to integrate it with the versions of widely deployed software available in those operating systems.

It is a fair point. It’s not productive or collaborative. It may be true, but ranting about it doesn’t help anyone but me.

More productive and collaborative would be to nicely ask these ISVs to establish a less isolated packaging process with our communities and companies (but I don’t mean LSB or a new package format). Clearly some people won’t work with them on ethical grounds, but a more pragmatic position will accept that commercial software exists, so it might as well not make our lives unnecessarily hard. And the companies shifting Linux are hot on ISVs.
Jorge: No, I don’t like having multiple JVMs, but I have been in corporate situations before where it has been necessary because specific applications have required different versions :(

Iphone shortcomings

July 27th, 2008 cmsj

There’s no doubting that the iphone is a hugely capable machine. It’s powerful yet easy to use, but it’s not perfect. Here are some things which I think are missing:

* DAAP - it would be great to be able to play music via wifi since the thing is a bit low on storage.
* Background apps - I understand the huge problems implied by this, but certain apps could be blessed with the ability. Either that or the excellent last.fm client should be integrated with the iPod app. Not everything can be made a push app (the api for which isn’t even available yet)
* IMAP subscriptions - I have loads of mail folders I don’t want to see, which is dead easy in most mail clients, because of the ability to only subscribe to certain mailboxes. I would like to see this in the iPhone mail client.
* IMAP new mail checking - I don’t have all my new mail go to my inbox, some gets filtered to other folders an I would like to be able to tell the mail client to check these too.