Emacs Movie Browser

See Emacs. See Emacs play movie

In the continuing story of Emacs@Home (don’t worry, I think there’s only one part left now), we’ve now come to the part where I watch TV.  I know, it’s something most people manage quite perfectly without resorting to Emacs, but why would you?

Well, actually, I think that the interfaces I’ve seen have been somewhat lacking.  Mostly mouse-based and not very practical.  I just want to sort by name or by recording date, and I don’t want to use an HTPC pointer device.  So:

User story: Keyboard-based and snappy.

Emacs is ready for its close up

Solution: Emacs.

I think this Emacs movie browsing interface demonstrates how little code you need to get a satisfactory result.  Emacs does all the difficult stuff for you, and presto! You have the interface as shown at the top there, displayed in blurrovision.  I just couldn’t get my camera to focus.  What if I take a the picture closer?  Yeah, that’s a bit better.

Anyway, I’ve got a little wireless keyboard next to me, and viewing a program just requires paging up and down a bit and hitting RET, which suits me fine.

Oh, and it just forks mplayer to actually play the movie.  Sorry, I didn’t implement H.234 decoding in Emacs Lisp.

Olde Stylee

So, not much code this time…  but it’s a bit interesting how writing about stuff like this changes the stuff itself.  Before starting to write this, the interface was even more minimal.  It didn’t have thumbnails and wasn’t in Futura.

The last picture there is how it used to look.  Just as functional (if you squint), but I thought “hang on, an Emacs interface without any pictures would be just to stereotypical”, so I added the thumbnails.

When writing software that I’m just going to use myself, it gets a lot more basic.  I get to embarrassed about the code quality, and I start cleaning it up, and before you know it, it has all these…  frills.  I’m not actually sure it’s a positive effect.  It might be.  Hm.

Anyway!

Sennheiser HDR 180

Headphones cradled on the charging cradle

Most hardware seems to have been created in a “will this do?” mind set.  They have a bit of technology, and they have some economic restraints, and then they rush it to market.  It makes perfect sense, and I can’t envision that it’ll ever change, but it’s somewhat depressing.

The hardware in question this week are the Sennheiser HDR 180 wireless headphones.  They use Klear wireless technology, and they sound really good.  There are no drop-outs, there is no buzzing — they just work, even if I walk to the far side of the apartment.  They’re, technically speaking, what you would call “ace”.

Cradle on/off button

But then there’s the User Experience details.

The headphones usually rest on the charger thingie you see up there.  It’s nice.  So when I start watching something on the “TV” and I want to use the headphones, I pick up the headphones and put them on my head?

Nope.

I pick up the headphones.  Then I hit the “on” button on the base station.  Then I hit the “on” button on the headphones themselves.  Then I put them on my head.

Headphone UX

Because, I mean, why would you assume that just because I’m picking them off the charging station, I want to use them?  Perhaps I want to do something completely different.  Perhaps I picked them off the charging station to hang them out to dry on the balcony?  Or perhaps I wanted to dance around with them, fondling them inappropriately?  I mean, that’s so much more likely than wanting to use them.

This is why I hate all hardware.  Hardware never works the way it should.

And I didn’t even want to go into the UX of the headphones themselves.  You see those five buttons on the headphones?  Yes, there’s volume up, on/off, and volume down buttons.  Fine.  But then, next to them, there’s two balance buttons.  So when I have the headphones on my head, which is usually where they are when I’m using them, I have to feel around, tentatively, for the volume buttons, because once you hit the balance buttons, you’ll never get the right balance back again.  There’s no “return the balance to the, er, balanced position” button. It’s like FAIL!!!1! And who the fuck wants to change the balance, anyway?

Oh, by Emacs.  I hate hardware.

Hardcore Food

I was looking through my cookery books for meatball recipes, and this was one of them.

It just seems too hardcore for me.  It starts with “half a kilo of meat from ox, calf, sheep, horse, moose, whale”.  And then you add blubber or lard or whatever “spekk” is.  And half a liter of milk.

Yum?

Quimby Upgrade

The old Quimby

Quimby (the machine doing everything at *.gnus.org) has been unstable lately.  (It’s died mysteriously two times.)  So instead of investigating what’s going on, I just installed Debian Squeeze on a new machine and rsynced over all the pertinent parts.  The old Debian installation was too stale, anyway, and 32-bit, so it was probably time.

The old machine (pictured at the top) was a self-built 2U machine with a couple of disks.  The new one is a 1U machine with dual dual-core 2.4GHz Opteron CPUs.  It’s ridiculously over-powered, but what are you going to do?  It was a six year old machine ready for the scrap heap.

The new Quimby

It is bemusing that a machine that old is that over-powered these days.  However, going further back in time is usually not very rewarding.  You get into serious problems with what kind of disks they’ll accept, for instance. Even this one was problematic.  It refused to boot up if there was a SATA disk larger than 500GB installed.  So I’d either have to use an external USB2 disk (which is not a very attractive solution) or use smaller disks and RAID5 them together.  I went for the latter option, but it’s still slightly exasperating that something as stupid as that should be a problem.  The last BIOS upgrade was from 2006, and didn’t help.

Oh, well.  The travails of a free software programmer.

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”
EndSection

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

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.