Alarm Clock

The alarm clock before I started writing this article

Most alarm clocks have somewhat awkward interfaces, which may be why so many people have switched to using their mobile phones instead.  Most mophos have alarm clocks that are easy to use — just open the clock app, choose a menu item and type in the time.  Especially for people like me, who doesn’t get up at the same time each day, using a traditional alarm clock is annoying beyond endurance.  It’s an outrage!  I’ll write my congresscritter!

Anyway, where was I?  Yes.  An alarm clock needs a numeric input pad. But, of course, I find using a mopho to be annoying, too, since I wake up all the time and need to be able to see what time it is before continuing to sleep.

I’m easily annoyed and sleep unsoundly.  There’s probably no connection between the two things.

Alarm clock control device

Anyway, I wrote an Emacs-based alarm clock, which, as a bonus, shows just how cold it is outside, too.  If it’s too cold, I just ignore the alarm and keep on sleeping. And it displays the time using the Futura type face.  How could you use an alarm clock with an inferior font?

To control the thing, I thought it’d be perfect to use a wireless keypad.  It allows me to set the alarm very easily (just type 8 RET of 730 RET). However, finding a keypad that had the required range turned out to be pretty difficult.  I went through five different ones before I ended up with this one, a Logitech N305.  All the other ones either only had a two meter range, tops, or were totally unreliable.  The N305 only has a single unusable key, the “Excel” key, so I use the rest of the keys to control the volume of the music and the lights in the bedroom.

MiniGoose temperature sensor
The new alarm clock. See? Much nicer. And warmer

Writing this it occurred to me that I had a spare tiny FitPC2 computer, and a 10″ USB-powered DisplayLink monitor that I had never used.  Instead of using the (really too big) eMachines all-in-one (seen at the top there) as the alarm clock, I could perhaps use the FitPC2 instead?

And I could!

DisplayLink technology is pretty new, and there are some quirks, so in case you have a similar setup and is Googling for how to get it to work under Linux (Debian Squeeze, Linux kernel 2.6.38), the rest of this blog entry is for you.

# lsusb -v
Bus 001 Device 005: ID 17e9:0288 Newnham Research

  idVendor           0x17e9 Newnham Research
  idProduct          0x0288
  bcdDevice           f0.02
  iManufacturer           1 DisplayLink
  iProduct                2 Monztor S10
  iSerial                 3 10270020

The iMo 10″ screen comes up as a cdrom device:

[    3.408147] sr0: scsi3-mmc drive: 8x/40x writer xa/form2 cdda tray
[    3.408372] cdrom: Uniform CD-ROM driver Revision: 3.20
[    3.409760] sr 2:0:0:0: Attached scsi CD-ROM sr0

So you have to use usb_modeswitch to switch it to DisplayLink mode:

usb_modeswitch -v 0x17e9 -p 0x0288 -u 1

After doing that, the screen should go green, but X won’t work on it.  Say the following:

rmmod udlfb
modprobe udlfb fb_defio=1

and you should now be able to start Xorg on the device.

Section “Device”                                                 
   Identifier  “MimoDevice”
   Driver      “fbdev”               
   Option      “fbdev” “/dev/fb0”

Section “Screen”                                                 
   Identifier  “MimoScreen”              
   Device      “MimoDisplay”   
   Monitor     “MimoMonitor”   
   SubSection “Display”                         
     Depth       16                      
     Modes       “1024×600”

See?  It couldn’t be simpler.

The Mimo USB monitor is quite nice, by the way.  It’s also a touch screen and a USB hub, but it’s not a floor wax.   However, the contrast leaves something to be desired, and the viewing angle isn’t very good. But it’s good enough to use as an alarm clock.

Adding Commands to mplayer

The computer I use to watch DVDs (and other stuff) with has three sound outputs: via HDMI to the TV, via the built-in analogue sound port to my wireless headphones, and via a USB sound card to external stereo speakers.  Which one I use depends on what I’m watching and what time of day it is.

So it would be nice to be able to change where the sound goes to on the fly. mplayer doesn’t have built-in support for it, but you could do this externally via a PulseAudio or the like, but since mplayer is occupying the screen and getting the commands, it seemed easier to just hack mplayer.

And, besides, each audio sink needs a different video/audio delay. The TV, for instance, delays the picture a bit, so if I’m listening over the headphones, I need to subtract a tenth of a second for the audio delay.  Or something.  I just experimented until I got something where Jon Stewart looked marginally less unhinged.

It turned out that adding commands to mplayer is really easy, but digging into the code this big can be pretty bewildering.  So if you ever want to add commands and keystrokes to mplayer, I’ve put the patch on the interwebs. It probably won’t apply cleanly to your specific mplayer version (and you wouldn’t want to, since it hard-codes my specific commands), but it should give you a rough idea of where to poke around.

An Emacs-based PVR

In the continuing story of me trying to push a few of the odds and ends of the code I’ve written for my own use, we’ve now come to the Emacs-based PVR. As usual, it may not actually be very useful code for, like, normal human beans, but why not push it out there?  Perhaps somebody will be inspired to do…  something.

So the story behind this piece of code is that I’ve never really been very fond of watching TV live.  I know, these days nobody does that any more, and everybody uses their cable company supplied (and crappy) PVRs, but back at the start of the millennium, it was a not un-novel idea.

USB TV card

And my implementation of it, based on Emacs, is probably noveller (that should be a word) than most.

So the idea is basically that we pull down the TV programme (thoughtfully provided by the XMLTV project), see what programs we want to record, and then record them.  It’s simple.  Since it’s Emacs-based, I can just ssh in to my machine from anywhere and add new programs to the list of stuff to be recorded from anywhere.  Take that, User Experience people.

The computer is hooked up to an external USB tv card that provides an MPEG stream.  So the actual recording is just “cat /dev/video0 > /tv/file”.

The nice little box running Linux

The cable company calls me sometimes and asks me if I kindly could consider switching over to digital cable, but then my PVR thingie would stop working, so that’s out of the question.  If analogue cable goes, I stop watching TV.

The only problem (for some values of “problem”) with this setup is that I can’t watch TV live easily even if I wanted to.  But I’ve been running stuff this way for a decade, and that hasn’t really tempted me more than a couple of times, so, eh, whatev.

Synology DS409 RAID is Crap

Do you see that thing over there?  The Synology Disk Station DS409?  It’s crap.

It’s not the usual hardware RAID problems that make it so crappy. 

Yes, it’s slow.  Painfully slow. 

Yes, it has a weird Linux kernel that, somehow, manages to do put all NFS clients into

df: `/mirror’: Permission denied

if you change any export permissions.  Any.  Not even on the volume in question. Or

df: `/mirror’: Stale file handle

if you reboot it.  How have they even managed to do that?

No, it’s not that.

It’s that if one of the disks break (as they are wont to do, which is why we have the “R” and “I” in “RAID”), which usually happens at 2am, the thing starts beeping.


Beep.  Beep.  Beep.

And there’s no way to turn the beeping off.  Other than switching the entire thing off.  So you have a redundant disk system, but if one of the disks break, it starts beeping so loud that it’ll wake all the neighbours, so you just have to switch it off until you can find a new disk to replace the old one.

So it’s redundant, but you can’t use it.  Ingenious.

The only thing I can recommend about the Synology DS409 is that it’s less unstable than any of the other commodity hardware RAID devices I’ve used.  Which means that as soon as 4TB disks become available, I’m going to just make a two disk soft RAID device and escape the horrible clutches of hardware RAID makers.

(I should make this blog into an electronic consumer review site, shouldn’t I?)

Running an RSS to NNTP Gateway

If I knew that doing an RSS to NNTP gateway was so easy, I would have done it years ago. I was just waiting for somebody else to pick up this obviously useful idea, but apparently nobody else wanted to.

In comparison to doing the Gwene gateway, the (almost) ten-year-old Gmane mail-to-news project is pretty mammoth, what with all the administration, spam work and web interfaces.  Gwene, on the other hand, is a minuscule collection of Perl scripts (find the source code on GitHub).

The main issue with parsing real-world RSS/Atom files is that, like HTML, they can’t reliably be parsed strictly.  None of the Perl RSS-parsing libraries seem to take this into account, and fail pretty badly on real-world feeds.  So the Gwene scripts have to pre-process the feeds before handing them over to the libraries, and then they have to root around pretty invasively into the Perl libraries’ internal structures to pick out the useful bits.

Somebody should extract the useful bits from the Gwene scripts and whip up a simpler DWIM RSS parsing library.  But I’ll leave that to somebody that actually knows Perl.