Archive for May, 2007

Watching TV: a simpler way

Wednesday, May 16th, 2007

MPlayer is a black art. GMPlayer, doubly so.

It turns out this does the job much better than my previous hacks:

#!/bin/bash
gmplayer -cache 2048 -zoom "dvb://$1"

It’s still not perfect for radio over digital TV, though - you get an empty window where the picture should be, and the cache is far too large for radio.

GSSMP 1.0

Saturday, May 12th, 2007

Get it here: http://gssmp.sourceforge.net.

This is the first time I’ve declared one of my projects stable, and given it a 1.0 version number.

Prove me wrong by downloading it and breaking it.

Enjoy.

Now I must dash - I’ve just got to finish off my other projects.

Choose channel dialog

Thursday, May 10th, 2007

Following on from the last post about how I got my TV card working, here is a little script I wrote that allows me to choose a channel and start watching. It uses zenity for a rudimentary GUI:

$ cat bin/tv_choose_channel
#!/bin/bash
awk -F ':' '{print $1}' < .mplayer/channels.conf  | \
    zenity --list --title "Choose Channel" \
    --text "Choose a TV channel to watch..." \
    --column "Channels" | xargs -IREP tv_watch "REP"

Digital TV on Dapper with my Hauppauge WinTV Nova-T card

Thursday, May 10th, 2007

My card reports itself like this:

$ lspci
*snip*
0000:00:0a.0 Multimedia controller: Philips Semiconductors SAA7146 (rev 01)
*snip

Everything seemed to work out of the box:

$ dmesg | grep DVB -A 0 -B 3
[17179585.872000] saa7146: register extension ‘budget dvb’.
[17179585.872000] ACPI: PCI Interrupt 0000:00:0a.0[A] -> Link [LNKC]
    -> GSI 11 (level, low) -> IRQ 11
[17179585.872000] saa7146: found saa7146 @ mem e0aa2000
    (revision 1, irq 11) (0×13c2,0×1005).
[17179585.872000] DVB: registering new adapter (TT-Budget/WinTV-NOVA-T  PCI).
[17179585.908000] adapter has MAC addr = 00:d0:5c:20:33:92
[17179585.908000] DVB: registering frontend 0 (LSI L64781 DVB-T)…

So, many, many hours of Googling later, and after many blind alleys and red herrings, I remembered (yes, I have indeed been through all of this before…) what I needed to do next:

scan /usr/share/doc/dvb-utils/examples/scan/dvb-t/uk-CrystalPalace > \
    ~/.mplayer/channels.conf

and, finally, to watch TV I just do this:

mplayer -zoom "dvb://BBC ONE"

That seems to fail sometimes, and this is more reliable:

$ cat bin/tv_watch
#!/bin/bash
TMPFILE=~/Desktop/tv.mpg
mplayer -dumpstream -dumpfile "$TMPFILE" "dvb://$1"  &
sleep 5
mplayer -zoom "$TMPFILE"
kill %1
rm -f "$TMPFILE"

which I run by simply typing:

tv_watch "BBC FOUR"

Update: the “scan” command is provided by the “dvb-utils” package on Ubuntu.

Restoring a backup with Duplicity

Wednesday, May 2nd, 2007

See the last post for how I back up my important files to a remote server. To restore them I do this:

duplicity --file-to-restore path/to/file.txt
    scp://user@example.com//home/example/bkp/home/andy/Maildir file.txt

and enter the passphrase when prompted.

Note that I can restore this backup even if I lose my entire home hard drive because it doesn’t rely on any key file - just my passphrase. This is less secure than using a private key file, but where do you back up your key file to? You know it will be lost when you need it … safer just to write down your passphrase somewhere, I reckon.

Remote encrypted backup with duplicity

Wednesday, May 2nd, 2007

My father-in-law’s hard drive died the other day and I was just able to recover the data using Knoppix and my iRiver. Since I recently discovered a superb program that lets me create encrypted backups on a remote server over ssh, I thought I’d spread the word. The program is called Duplicity and it is simplicity itself to use. Here is my remote backup script:

#!/bin/bash
# Copy this to /etc/cron.weekly and make it executable and owned by root # Back up my most important stuff from the local machine to a remote # server, encrypted with a passphrase function run_duplicity { echo Backing up ‘$1′ … PASSPHRASE=`cat /root/.blah/passphrase` duplicity $1 \ scp://user@example.com//home/example/bkp$1 } run_duplicity /var/lib/mysql/dbtobackup run_duplicity /home/andy/Maildir

I have one “run_duplicity” line for each directory I want to back up securely. I have my passphrase in a file only reeadable by root in /root/.blah/passphrase, and you either have to type your ssh password each time you run the script, or you can set up a key to let you log in automatically using ssh-keygen.