Zed Lopez

I Bought a Duplex

My venerable HP Laserjet 1012 gave up the ghost this weekend. I replaced it with a spiffy new Brother HL-2270DW. It’s noticeably faster, capable of higher resolution (not that I have any need for better than 600x600), and has a wireless feature I haven’t tried to use because it’s sitting next to a computer.

But that’s not what I’m here to talk about.

The D in DW is for duplex. It can print on both sides of a sheet of paper. I remember being excited about a duplex printer for under $300 back in 2001; not the first time I wanted such a thing, but the first time it seemed within reach.

At various points in the meantime, I’ve tried manual duplexing – printing the odd pages in reverse order and putting them back in to print the even. I sang the praises of gnome-manual-duplex with automated this to the extent possible.

And I’ve probably wasted as much paper as I’ve saved in the process. As the printer got hot from printing a stack of pages, the chances of it grabbing two pages at once grew, and then everything thereafter was wrecked. To fight that, I’d print in small batches. But even when it worked, it was a pain in the butt, requiring running into the next room to reload the printer for each stack.

Duplex has been thoroughly in reach for a while row. The HL-2240D gets down to $60 on sale. But it seemed so hard to justify while the 1012 was still working.

And maybe that was a bad call, because watching it suck the paper back in to print a perfect double-sided page almost makes me cry, it’s so beautiful.

Zed and Malasada at Home

M: There’s no place in Berkeley where you can get Italian cookies like you can get on the east coast.

Z: Sure there is – the Virginia Bakery is an Italian-style bakery.

M: No, they wouldn’t have those.

8 YEARS LATER

M: Hey, do you remember when I said you couldn’t get Italian cookies in Berkeley, and you told me the Virginia Bakery had them, and I said they didn’t?

Z: Yeah.

M: Well, I finally went to the Virginia Bakery. And they have them!

Z: Mm-hmm.

M: Why didn’t you tell me you were right?!

Z: …

The Ducks Must Be Crazy

A while back, I blogged about a patent rejected due to prior art in a Carl Barks comic.

I’m reading Only a Poor Old Man, Fantagraphics’ Uncle Scrooge reprint, and see that Barks anticipated the premise of The Gods Must Be Crazy by some decades. In Uncle Scrooge #6 from June, 1954, in the story Tralla La, Scrooge McDuck drops a bottle cap from a plane (instead of a bottle, as in Gods) into a Shangri-La-esque valley in the Himalayas where its scarcity wreaks havoc on an isolated society used to there being plenty of everything for everyone.

Flipping the Shelf

A couple of shelves in one of my bookcase were bowing under the weight of heavy role-playing game books. Prompted by a comment in an RPG forum (I’d link to it, but I’ve forgotten where exactly) I took the obvious in hindsight measure of flipping the shelves over.

Sometimes it’s easy.

Off the Main Sequence

I mentioned a while ago that the three Heinlein stories that he hadn’t allowed to be reprinted in his lifetime had finally been collected.

What I didn’t realize then was what a service to the Heinlein fan the SFBC had done with the collection, Off the Main Sequence. It is all of Heinlein’s short stories that aren’t in The Past Through Tomorrow. With these two books, you don’t need any other collection (including Orphans of the Sky, which is a fix-up of two novellas.) This and the 32 novels are all you need for the complete fiction.

But completists (who aren’t rich enough completists for the Virginia Edition) will want to keep their Revolt in 2100s for the non-fiction Concerning Stories Never Written.

New Blog

My blogging has languished for a long time while I’ve meant to get around to moving it to zedlopez.com and away from Movable Type. So I’m finally here with a spiffy new Octopress instance. Irregular programming will resume.

Pfind

File::Find is a very nifty perl module on CPAN for finding files by whatever criteria and operating on them. Its docs say:

See also the script pfind on CPAN for a nice application of this module.

which becomes a little cryptic when you see there is no pfind on CPAN. But here’s pfind and it’s a pretty nifty tool to have alongside ack for replacing complicated find/grep pipelines.

NAME

pfind – find-or-grep-like utility with Perl syntax

SYNOPSIS

To lowercase only the files names of which contain “blah”, do


pfind . /blah/ ‘$_ = lc’

To lowercase only the files which contain “blah” inside, do


pfind . “=~ /blah/” ‘$_ = lc’

To do recursive “grep foo bar*” in UTF-8 files, do


pfind -utf8 -alllines . ‘/^bar/’ ‘=~ /foo/’ prt_line

DESCRIPTION

usage:


pfind debug] [-nosubdir] [-bin] [-bak=suffix] [-alllines] [-utf8] [-vars] [-nochdir] [-opts=OPTIONS] [- startdir rule1 rule2 …

Rules: filters and actions

Rules are perl statements to execute. Statements starting with “-”, “/”, “$dir =~”, “$dir !~”, “$name =~”, “$name !~”, or “!” are considered filters, a file will be discarded unless the statement returns true.

Statements starting with “=~” (possibly negated by prepending “!”) are filters applied to the contents of the file. The rest is executed as is.

Rules are executed in the directory of the file.

Netselect-if

If you’re like me, you’ve wondered which Interactive Fiction Archive mirror is fastest for you. Wonder no more!
    #!/usr/bin/env ruby

require 'open-uri'
require 'hpricot'

doc = Hpricot(open("http://www.ifarchive.org/"))
mirrors =(doc.search("div.ArchiveMirrors")/"a").map {|a| a['href'].strip.match(/^[^\\/]+\\/\\/([^\\/]+)/)[1]}.reject {|m| m == "mirror.ifarchive.org"}.uniq
system(*(%w(netselect -v -s 5) + mirrors))
  

Things I Learned

Perl’s DateTime module can (usually) figure out the local timezone on its own. Don’t know why I didn’t know this — it’s right there in the docs.

our $App::LocalTZ = DateTime::TimeZone→new( name => ‘local’ ); … # then everywhere else my $dt = DateTime→new( …, time_zone => $App::LocalTZ );

It’s straightforward to convert a static library to a shared one

ar -x mylib.a
gcc -shared *.o -o mylib.so

catdoc converts doc and rtf files to text, and, so far in my brief acquaintance with it, does so better than antiword and unrtf. And it comes with xls2csv and catppt as well.

axi-cache is a lot more useful than apt-cache for searching through debian package info. It’s part of apt-xapian-index which uses Xapian to index the data.

Status Bar Datestamps Made Easy

Suppose you want to represent the days of the week with one character each.

MTWTFSS

Oops, two ambiguities in a domain of just seven. Tuesday and Thursday may begin with the same letter, but not the same sound, so we can just throw in the IPA for the voiceless dental fricative, one of the sounds represented in English by the digraph /th/.

MTWθFSS

But we still have to disambiguate Saturday and Sunday. OK, Sun is for Sunday — what could be more clear?

MTWθFS☼

That’s the Unicode “white sun with rays”. It’s a little hard to distinguish from a snowflake or a squashed bug at regular text sizes. But if you tend toward light text on a dark background, like me, the “black sun with rays” works better.

MTWθFS☀

Black Sun was also an X-Men miniseries. Black Sun was also a Wildstorm character. Now that Wildstorm is being rolled into the DC Universe, there could be a Black Sun with rays series.

But a sun-eater is cooler.

I seem to have digressed. Anyway, there’s a perfectly good alternative symbol for the Sun lying around, the alchemical symbol.

MTWθFS☉

But if we’re going alchemical, why should Saturday get the S? Saturn’s got its own alchemical symbol.

MTWθF♄☉

And Saturn’s not the only one. Just look at the days of the week.

Moon day
Tyr’s day
Wotan’s day
Thor’s day
Freya’s day
Saturn’s day
Sun day

In the interpretatio germanica, Tyr is Mars; Wotan is Mercury; Freya is Venus; Thor is… well, Thor is Hercules, but Thor’s Day is Jupiter’s day. So now we have:

☽♂☿♃♀♄☉

I expect strftime to support this any day now. In the meantime, this convenient Perl one-liner breaks it down.


perl -e ‘binmode STDOUT,:utf8";print chr((0,0×263D,0×2642,0×263F,0×2643,0×2640,0×2644,0×2609)[(localtime(time))6])’

New Netbook. But Mostly Windows-bashing.

I finally bought a netbook, an Asus EEE PC 1015PEM-PU17. Purportedly, there should be EEE PCs available with Linux, but I don’t see those actually for sale, so I ended up paying the Microsoft tax and receiving it with Windows 7.

I decided to leave it there, both because it’s a useful beard (no one’s going to suspect you’re concerned with security if your machine boots into Windows), and because it would be difficult or impossible (it didn’t come with OS CDs) to restore it after the fact, which I might want to do to resell it. Some people would actually want it that way. Takes all kinds to make a world.

So I planned to do the minimally intrusive thing and install Linux to the 100+ GB empty D: drive it was set up with. But I wasn’t sure whether Windows would end up confused if I simply reformatted that out from under it, so I wanted to delete the partition within Windows. Which meant interacting with it.

This was my first experience with Windows 7. I never used Vista, and I’d heard a lot of good things about 7. From my brief and shallow interaction with it, I couldn’t see much difference from XP. You’re still not prompted to make a separate admin account from your ordinary user account. That was a bad call ten years ago, and it’s a bad call now. I tried to figure out how to delete the partition, and I could find a couple of places to get at info about the drives, but no luck, so I resorted, of course, to Googling.

Start Menu > Control Panel → All Items View → Administrative Tools → Computer Management → Storage → Disk Management. Mmm, can’t you just smell the discoverability? The intuitiveness? I’m not suggesting that this is harder than it would be in Linux, of course, where you’d also need to google to find that you wanted parted. But once things are so complicated you’re resorting to web searching to figure out how to do what you want, I’m hard-pressed to see how navigating through 7 levels of interface is any easier, either. Sure does involve more pointing and clicking, though - gotta give it that.

I did the web-searching in MSIE. Had a wonderful Windows moment in which it immediately prompted me for whether I wanted the Bing bar. I said no. Another box popped up saying the Bing Bar wanted to run some software. Did I want to let it? I said no. Back to the first box. You see, you have to say yes to the second box to let it run software (which is actually an uninstall program, but you’re not told that) in order to effect your no to the first box.

Meanwhile, there were things popping up all over the place with Trend Micro this and Asus Warrantee that. These aren’t directly Windows’ fault, but they are of a piece with the software ecosystem of irritation that has grown around Windows. I made the mistake of walking away from the computer and lying down on the couch, and nearly as soon as the kitty had settled on my chest, it started playing annoying music. The default screensaver was some sort of instructional/advertisement video.

As usual, I wondered how people could live this way.

So I deleted the partition and installed Ubuntu 11.04. I thought I’d try another Debian Unstable derivative, but I shopped around and really didn’t see that anything else offered a comparably attractive combo of currency, stability, and support. Maybe tomorrow I’ll dist-upgrade to the 11.10 Alpha 3.

And then I spent several hours installing software and in a couple of important cases, like for my window manager and terminal emulator, downloading the source so I could have the latest versions compiled with exactly the options I wanted, and generally did a lot of things that would leave most people wondering how I could live that way.

But absolutely nothing pops up.

Not even when the battery runs dry.

Yeah, I need to do something about that one.

Updated: Lest I mislead anyone, the defaults for most of the Linux installations in this modern world already take care of laptop battery warnings without thought or effort on the user’s part. It’s because of my extreme customization that I’ll need to do something myself.

RequestPolicy: Web Security the Right Way

Firefox remains my primary web browser of choice, principally because of the privacy extensions available, the most important of which are Cookie Monster and NoScript. But I’ve been frustrated by their limitations — I don’t want to just blacklist and whitelist, but to conditionally allow select 3rd party cookies to be set and scripts to be run depending on what the page is and what the 3rd party is. I want to be able to say that for paypal.com, requests to paypalobjects.com should be treated the same as paypal.com without globally whitelisting paypalobjects.com.

So I’m mortified it took me so long to find out about RequestPolicy, which simply denies cross-site requests in general unless they’re allowed, and supports allowing them on a per site basis.

It doesn’t do everything I’d like; I’d like a lot more granularity, which would require a more complex interface than its author is going for. But it’s better than anything I’ve seen.

And it’s weird for me to realize that blocking cookies becomes scarcely relevant with third-party requests denied by default. What I really wanted to avoid was advertising sites or javascript library providers being able to build a picture of my browsing history. Now I have to wonder if I even need Cookie Monster at all.

Fun With PDFs

I’ve bought some role-playing game PDFs in recent weeks. A bunch of them are formatted for 6″×9″ pages (in part inspired by optimizing for iPads.) But I don’t have a tablet, or a large reader, and printing out pages that small on letter-size pages would be a big waste.

This is why pdfjam is my new best friend.

First, I examine the PDF to see which pages I want to keep, skipping any ads and often the covers or license text. Depending on the layout, it might be important to maintain what’s recto and verso, but here I don’t.

pdfjam sotc-electronic-edition-regular-20060914 ‘3,5-419’

I have

paper=letterpaper
in my

/etc/pdfjam.conf
, so this automatically converts to letter size.

This leaves me with those pages in sotc-electronic-edition-regular-20060914-3,5-419-pdfjam.pdf. pdfjam and its sibling, pdfnup, are nicely predictable in this regard.

Now I’ll put them two to a page, scaling up the size a little.

pdfnup sotc-electronic-edition-regular-20060914-3,5-419-pdfjam.pdf —nup 2×1 —scale 1.1

This leaves me with a ginormous white river in the middle of the page. pdfnup offers various cropping and moving options, but I don’t see that you can move left pages a little to the right and right pages a little to the lift, which would be ideal for me.

Last up is rotating the pages to portrait orientation.

pdf90 sotc-electronic-edition-regular-20060914-3,5-419-pdfjam-nup.pdf

My new next-best-friend is gnome-manual-duplex. But I don’t want to just dump the whole thing to the printer, because any mistakes (like the printer grabbing two sheets at once) would ruin the rest of the stack. So I break it up. (Obviously, it’s important to start on an odd page and finish on an even page.)

pdfjam sotc-electronic-edition-regular-20060914-3,5-419-pdfjam-nup-rotated90.pdf 5-52 -o out.pdf

I’ve symlinked

/usr/local/bin/duplex
to

/usr/bin/gnome-manual-duplex
, so:

duplex out.pdf

Ubuntu 10.04 Disappointment

This weekend I brought Malasada’ computer up to Ubuntu Lucid. Yes, there’s a more recent version, but the other machines in the house are Lucid; I didn’t see anything compelling in Maverick; I figured Maverick’s younger and the kinks were likely to have been worked out of Lucid; it’s a long-term-support release, so if I feel lazy and there are no compelling reasons to upgrade, I can go without for up to three years.

It’s the first machine I’ve installed with ubuntu-desktop — the others were lovingly hand-crafted starting from command-line-only installations. So it was my first time encountering the things people have been complaining about. Ugly default desktop background — easily changed. Window icons on the left — easily changed. Ubuntu One in the main menu — easily changed.

But it’s also the first time I installed it on a machine with an Intel graphics chipset. And every few seconds the screen flickered black. And lots of people are having this problem and have been having it for months. And it’s not fixed. People are giving up and using Maverick, or Maverick’s kernel, or Karmic’s kernel.

According to the threads on the subject, changing boot options fixed it for some people. I tried a couple of the suggestions and they didn’t work. Switching from a DVI cable to a VGA cable worked and, in practice, I don’t see any quality degradation, so I guess I’ll live with it.

I’m not interested in a lot of the things Canonical’s been pursuing, but have continued to be an Ubuntu user because it’s been a good way to get an up-to-date, supported Debian derivative that just works.

But if you take away the just works part, then, well, I may be looking elsewhere next time I’m looking to upgrade.

Mplayer for Realvideo in Firefox

I recently had to test web delivery of a RealVideo file. This solution is crude and not robust. But it was quick (and it had to be quick to justify hacking my own vs. actually installing Realplayer in some environment.)

Dumped this in /usr/local/bin/realplayer:

#!/bin/bash
cd /tmp
wget $1
mplayer `cat $1`

I stopped Firefox, and in mimeTypes.rdf in my firefox profile (and this seems needlessly convoluted):

Within

<RDF:Seq>
, I added:

<RDF:li RDF:resource=“urn:mimetype:video/vnd.rn-realvideo”/>

Within the root element, <RDF:RDF>, I added:

<RDF:Description RDF:about=“urn:mimetype:video/vnd.rn-realvideo” NC:value=“video/vnd.rn-realvideo” NC:editable=“true” NC:fileExtensions=“ram” NC:description=""> <NC:handlerProp RDF:resource=“urn:mimetype:handler:video/vnd.rn-realvideo”/> </RDF:Description> <RDF:Description RDF:about=“urn:mimetype:handler:video/vnd.rn-realvideo” NC:alwaysAsk=“false” NC:saveToDisk=“false” NC:useSystemDefault=“false” NC:handleInternal=“false”> <NC:externalApplication RDF:resource=“urn:mimetype:externalApplication:video/vnd.rn-realvideo”/> </RDF:Description> <RDF:Description RDF:about=“urn:mimetype:externalApplication:video/vnd.rn-realvideo” NC:path=“/usr/local/bin/realplayer” NC:prettyName=“realplayer” />

Restart Firefox, presto, mplayer is working as my realvideo player.

Escape From the Shell

Perl’s exec, system, and fork functions all let one execute system commands, and they all do it by driving a POSIX exec system call so they don’t invoke a shell. But Perl’s backtick operator (aka the qx quotelike operator), the easiest way to capture output from a command, invokes a shell, so the arguments to the command need to be shell-escaped.

Sysadm::Install has quote and qquote functions that do a good job of this, but it’s easy enough to avoid needing shell escaping.
sub command {
  my ($command, $dontchomp) = @_;
  $dontchomp //= 0;
  open(my $ph, qq{$command|}) or die "Can't fork $command: $!";
  my $raw = do { local $/ = <$ph> };
  close($ph) or die "$command returned error: $! $?";
  chomp $raw unless $dontchomp;
  return wantarray ? split "\
", $raw : $raw;
}

Note that you pass the whole command line as one string, arguments and all. The default behavior is to chomp the command output, which differs from the native backtick behavior; you can pass a true value for the second arg, $dontchomp, if you don’t want it.

Reading all the output into a scalar is suitable for things with modest amounts of output (like the situtations in which you would have been using a backtick.) If you were processing a lot of output, you’d want to open the pipehandle and iterate on <$ph> yourself.

The reason I went down this rabbit-hole is wanting to get info from ratpoison so I could write some window management scripts. When you pass ratpoison a command with its -c option, it expects the whole command as one string. So we do have to worry about quote-escaping that string, like so:

sub rp {
  local $_ = "@_";
  s/"/\\\\"/g;
  return command(qq{ratpoison -c "$_"});
}

The way this is written, you can pass your arguments as a string or as a list, to taste.

rp("windows %c %t %n");
rp("windows", "%c", "%t", "%n");

Ratpoison lets you pass it multiple commands at once, and this rp routine doesn’t, but that’s usually what you want when you’re getting info out of it.

CPAN Handling

Later the same week I was having problems building a Python package, I rounded out my fun by having problems building a Perl package.

I learned that <prefix>/perl/<version>/Config.pm includes the various flags and settings that your perl was built with, and can be your guide to how to build things to play nice with your Perl instance. (Module::Build tries to do this automagically, but it wasn’t working with the idiosyncrasies of the environment I was working with.)

Not an Ez_setup

I was trying to build a Python module yesterday, but

python setup.py build

insisted on including several compiler options that the compiler immediately balked at, returning an error. This is despite that the instance of Python I was using was freshly compiled with the same environment, so shouldn’t have any mistaken notions of how things should be built.

setup.py went:


if os.name == “posix”:
from setup_posix import get_config
else: # assume windows
from setup_windows import get_config

metadata, options = get_config()

  1. other assignments to metadata
    setup(**metadata)

so I just used pprint to look at options:

import pprint
pp = pprint.PrettyPrinter(indent=2)
metadata, options = get_config()
pp.pprint(options)

I saw that the unwanted compiler options were coming from

options[‘extra_compile_args’]
so I set that to the null list, and now I could build it.

Also, I got to find out that the 3 year old release version of mod_python 3.3.1 has a bug that causes compilation errors on some platforms (including mine, Solaris 2.10.)

Ratpoison Titlechanged Hook

A tiny patch I wrote was just committed to the ratpoison git repository. It adds a hook called “titlechanged” that allows you to configure actions to be taken when the current window’s title is changed.

My patch included a one-line description of the hook in the manual. It’s accurate enough, but by itself it remains one of those things that would leave you thinking “OK, so I can do this, but why would I want to?”

So this entry is my explanation of why you might want to.

One of the points of ratpoison is that it just draws windows, with no titlebar or other window decoration (save for an optional border.) Most of the time, I find this to be a feature — the titlebar rarely adds anything useful, so it’s usually wasted space. But I sometimes found it to be a bug when using a web browser, when the window title is whatever’s the contents of the current tab’s title tag, info that isn’t necessarily duplicated elsewhere and occasionally has value.

At some point, I toyed with a greasemonkey script that would reproduce the title in the body of the html in some distinctive style, but it was a pain. It took a while, but eventually I struck upon my current course and realized just how easy it would be to add the necessary support to ratpoison. (I programmed in C for five years in my first job out of college, but that was a long time ago, and I wouldn’t claim to be a C programmer today. But the ratpoison source is so clean and clear, the patch was straightforward.) And it’s a relief to know I’ll never want to cobble together an application-specific workaround again.

How I’m using it relies on inotail and dzen (compiled from source for xft support, which the Ubuntu Lucid package doesn’t have.)

In my .xsession, I have:

[ -f /tmp/left ] && rm /tmp/left
[ -f /tmp/right ] && rm /tmp/right
touch /tmp/left
touch /tmp/right
killall dzen2
inotail -f /tmp/left|dzen2 -x 0 -w 400 -ta l -fg “#1F1F1F” -bg “#CFCFD7” -fn “Consolas-11” &
inotail -f /tmp/right|dzen2 -x 400 -w 1280 -ta r -fg “#1F1F1F” -bg “#CFCFD7” -fn “Consolas-11” &
/usr/local/bin/status.pl &
ratpoison

In my .ratpoisonrc, I have:

set padding 0 16 0 0
addhook switchwin exec ratpoison -c “info %t” > /tmp/right
addhook switchframe exec ratpoison -c “info %t” > /tmp/right
addhook deletewindow exec ratpoison -c “info %t” > /tmp/right
addhook titlechanged exec ratpoison -c “info %t” > /tmp/right

“set padding” leaves 16 pixels at the top of the screen for the dzen2 bar, suitable for 1 line of Consolas-11. The hooks update /tmp/right whenever a potentially title-changing event occurs. (I was tempted to fire the titlechanged hooks in ratpoison as a side effect of the other hooks, but no other hook in ratpoison chains in that fashion, and I chose not to.)

Meanwhile, /usr/local/bin/status.pl writes to /tmp/left to update the left 400 pixels with the time and current CPU temp.

#!/usr/bin/perl
my $font=“Consolas-11”;
my $fg=“#1F1F1F”;
my $bg=“#CFCFD7”;

while (1) {
open(KID_TO_WRITE, “>/tmp/left”) or die “couldn’t open /tmp/left: $!”;
my ($sec, $min, $hour) = localtime(time);
my $time = sprintf “%02d:%02d”, $hour, $min;

my @sensors = split "\

“, `sensors`;
my ($systemp, $core0, $core1);
for (@sensors) {
/^Core 0/ && do { /(\d+\.\d+)/; $core0 = sprintf “%2.0f”, $1; };
/^Core 1/ && do { /(\d+\.\d+)/; $core1 = sprintf “%2.0f”, $1; };
}
print KID_TO_WRITE "$time ", (join “/”, $core0, $core1), "\
“;
sleep 15;
close KID_TO_WRITE;
}

I’m not using dual monitors at the moment. This setup would need some revision for that case; I’d probably want different dzen bars per screen (and I’d assign something to a switchscreen hook in ratpoison.) And the static width of the dzen bars wouldn’t do the right thing with screen rotation, something I’ll address at some point.

What I Tell You Three Times Is True

Two science fiction novels I love pay tribute to The Hunting of the Snark with turning points in which computers allow otherwise unauthorized behavior when the user tells it something three times. (I’m not mentioning which novels, because it’s a major spoiler for one of them.)

They have inspired this utterly brilliant idea:

Set up some pre- and post-processing of command lines in your shell so that it has a history of return codes as well as a history of the command lines themselves.

If a given command is identical to the two previous commands entered, and the two previous commands exited with identical non-zero return codes, automatically escalate privilege to root.

What could go wrong?

Why I Almost Left Ubuntu

It’s hard to believe, but I’ve been using Ubuntu for about 6 years now. I’d been using Gentoo beforehand; I’ve come to like the Debian packaging system, repositories whose intra-operability had been extensively tested (at least after release…), but with the regular release schedule putting a reasonable bound on getting recent versions of apps. And Malasada is happy with her Ubuntu (Gnome) desktop, and it’s convenient to have all the machines in the house on the same OS.

But I don’t have any use for Gnome, or KDE, or desktop environments in general. I start with a command-line system, install X, build ratpoison from source (with a patch of my own), build rxvt-unicode from source (because even Lucid’s package is one release behind, missing the crucial letterspace adjustment feature), build dzen2 from source (for xft support)… in short, I was acting more like an Arch Linux user. And I was often finding the Arch wiki and forums more helpful than Ubuntu’s, given how often the latter’s advice was desktop environment-centric. I figured why fight it? I’d give a distro more or less aimed at compulsive customizers a go.

So I did. I have a draft blog entry lying around talking about it, which was mostly positive. But I gave up due to a fatal flaw that I suspected (and am now confident) wasn’t Arch’s fault. This bug in which mode_switch is intermittently locked may be common to all instances of Xorg’s Xserver >= 1.7. Harmless for the majority who’ve never Xmodmapped a mode_switch key into existence or mapped a keyboard layout that relied on it. But if you have, it makes your system unusable. At first I’d thought my keyboard was dirty and sticking, but it persisted with a new keyboard.

I wasn’t willing to unlearn my custom keyboard layout, and didn’t want to learn how to do it in XKB having found that a frustrating exercise when I’d looked into it before, so I thought I’d install the Ubuntu Lucid pre-release (I think it was the last Alpha.) My latest machine didn’t have a CD drive, so I was installing with a USB CD drive. And after starting, the installer complained it couldn’t find the CD drive, would I like to provide a driver on floppy? This was when I remembered I’d had the same problem with Karmic. So, like I did then, I started with Jaunty, planning to dist-upgrade for there. Which I did. But whether it was due to my manually configured LVM/crypto configuration or an Alpha bug, the two dist-upgrades left me with a system that froze on the Ubuntu boot screen.

Screw it, thought I, and I downloaded and burned a Debian Squeeze installer. There wasn’t a heck of a lot of distance between Ubuntu and Debian the way I did it, anyway.

That was when I found out that whatever the problem was with the USB CD driver, it was something Ubuntu inherited from Debian.

Screw it, thought I, and ripped the one SATA DVD drive in the house out of its machine and installed it in mine (my current machine has a Zotac Ion mini-ITX motherboard with no IDE headers.) I started over with Lucid.

Shortly thereafter, I encountered the same X issue. So I had to break down and learn how to map my keyboard in XKB. If mode_switch and xmodmap are so marginal that a problem of those magnitude can stand, it’s probably time to throw in the towel and get with the modern technique.

So after all of that, I’m back on Ubuntu, with no reason I couldn’t switch back to Arch, except that all my tolerance for installing OSes has been used up for some months to come.

Adventures in Ubuntu Lucid, Mythtv, and the Hauppauge HVR-2250

saa7164-stable won’t compile with Lucid’s kernel due to some name changes in recent kernels. One needs to use saa7164-dev.

Compiling saa7164-dev errors out at first, too. But after

make
creates v4l/.config, you can change CONFIG_DVB_FIREDTV=m to CONFIG_DVB_FIREDTV=n

The instructions to extract and install the firmware are outdated with little attention being called to the fact. Follow the directions to get dvb-fe-tda10048-1.0.fw in the right place, but then download v4l-saa7164-1.0.2-3.fw and v4l-saa7164-1.0.3-3.fw directly and save them to /lib/firmware/`uname -r` (or /lib/firmware/2.6.32-20-generic at the moment for an up to date Ubuntu Lucid.) (I’ve also put all 3 directly in /lib/firmware, but that’s probably redundant.)

Once you’ve gone through all of this, and done a

make install
,

modprobe saa7164
should make your system recognize the card. But the devices are owned by group video, and ordinary users aren’t a member of it to start with. so

adduser yourusernamehere video
. (Remember that it won’t take effect in existing logins.)

Lucid’s mythtv is reasonably up-to-date and I’ve found no reason so far to seek out a more recent one.

I followed these instructions to migrate my old mythtv recordings to the new server (I followed the advice in a comment there to use —complete-insert, though it may not have been necessary.)

After installing mythtv, I found that its channel scan was having some trouble finding everything. So I did a

wajig install w-scan dvb-apps
, did a

service mythtv-backend stop
to make sure there was no competition for the card, and:

w_scan -x -f a -c us > w_scan.out
scan w_scan.out > w_scan_channels.conf
scan /usr/share/dvb/atsc/us-CA-SF-Bay-Area > scan_channels.conf
cat w_scan_channels.conf scan_channels.conf|sort|uniq > channels.conf

Then in mythv-setup I pointed it at channels.conf to do its scan.

mythtv-backend was being started before the devices for the video card had been created, which resulted in errors in the log, though I’m not sure whether the situation was causing any real harm. At any rate, inspired by this comment I put this in /etc/init/mythtv-backend.conf:

  1. MythTV Backend service

description “MythTV Backend”
author “Mario Limonciello <superm1@ubuntu.com>”

  1. modified per http://swiss.ubuntuforums.org/showthread.php?t=1345079&page=2 to wait for devices
    start on (local-filesystems and net-device-up IFACE=lo and started mysql)
    stop on starting shutdown

#expect fork
respawn

pre-start script
LOG_FILE=/var/log/mythtv/mythbackend-init.log
. /etc/mythtv/mysql.txt
\t#get the tuner card paths
\tTUNERS=`mysql —user=${DBUserName} —password=${DBPassword} —database=${DBName} —skip-column-names —execute=‘SELECT DISTINCT videodevice FROM capturecard;’`
\techo “`date`: Mythtv-backend Upstart; tuners found in database: ${TUNERS}” >> $LOG_FILE
\tfor t in $TUNERS
\tdo
\t\twhile [ -c !$t ]; do
\t\t \techo “`date`: Mythtv-backend Upstart; tuner device ${t} is not ready. Waiting 1 second…” >> $LOG_FILE
\t\t\t \t sleep 1s
\t\t\t\t \t done
\t\t\t\t\t\techo “`date`: Mythtv-backend Upstart; tuner device ${t} is now ready” >> $LOG_FILE
\t\t\t\t\t\tdone
\t\t\t\t\t\techo “`date`: Mythtv-backend Upstart: tuner devices are now registered. Starting mythbackend” >> $LOG_FILE

end script

script
test -f /etc/default/mythtv-backend && . /etc/default/mythtv-backend || true
/usr/bin/mythbackend $ARGS
end script

Now all I have to do is find out why there’s no sound (probably something independent of mythtv), why, even after all that scanning, it’s not finding KQED (almost certainly having to do with the antenna), and why playing videos in mythfrontend causes the system to reboot after a few seconds (!)