Tuesday, 30 October 2007

Ubuntu, Dell laptop and hard disk power management

There has been some talk those days on laptop hard disk lifespan. See, for example, what Pascal says about it.

So, after some investigation, I saw that on my laptop (Dell Latitude D420) the BIOS doesn't handle an APM value of 255. By default the startup scripts execute hdparm -B 255 /dev/sda (or other devices) and that actually sets the APM value to 128 (as given by hdparm -I /dev/sda | grep Advanced). (I'm using Ubuntu 7.10 -- the script I'm talking about is /etc/acpi/power.sh.)

On the other hand, using -B 254 seems to disable APM. So here's a way to do it, by default, on every boot:

  • Add those lines to /etc/hdparm.conf:
    /dev/sda {
    apm = 254

  • Make /etc/init.d/hdparm run at startup:
    ln -s /etc/init.d/hdparm /etc/rcS.d/S07hdparm

And now the load cycle count reported by SMART remains stable. Which means that hopefully my hard disk will live longer.

Addendum: if you don't use SMART, you should. Install the smartmontools package, enable SMART on your disks with smartctl -s on, and read the smartctl(8) manpage. Optionally, enable the smartd monitoring daemon (via /etc/default/smartmontools).

Wednesday, 24 October 2007

urxvt + perl

I'm playing with urxvt (a.k.a. rxvt-unicode), a fully Unicode-aware terminal forked off the popular rxvt.

One of the good things with it is that it's fully scriptable in Perl. Here's my first attempt, a small plugin that adds an item in the popup menu (given by the standard Perl plugin selection-popup) to draw in bold font whatever matches the selection. It's not extremely useful, but that's a start.

our $selection_hilight_qr;

sub on_start {
my ($self) = @_;
$self->{term}{selection_popup_hook} ||= [];
push @{ $self->{term}{selection_popup_hook} },
sub { hilight => sub { $selection_hilight_qr = qr/\Q$_/ } },
sub { 'remove hilight' => sub { undef $selection_hilight_qr } };

sub on_line_update {
if (defined $selection_hilight_qr) {
my ($self, $row) = @_;
my $line = $self->line($row);
my $text = $line->t;
while ($text =~ /$selection_hilight_qr/g) {
my $rend = $line->r;
for (@{$rend}[$-[0] .. $+[0] - 1]) {
$_ |= urxvt::RS_Bold;

As you can see, this code is pretty small (although not very readable maybe -- I dislike using @+ and @-, but my urxvt isn't compiled against a Perl 5.10 :).

Well, I'm now looking for ideas. What would be cool for a terminal to do for you (and that urxvt doesn't already provide?)

Monday, 8 October 2007

New camera

I just got a new camera, a brand new Canon PowerShot A720 IS. Very nice compact camera. Great optical zoom (6x). Possibility of manual settings. Nice UI (so far). There's no detailed user manual, though -- I still need to learn how to program my modes, etc.

I spent my sunday playing with it. I've uploaded a couple of shots to flickr -- more, of course, are to follow.