It seems that the cd player that came with Gnome, Grip has an option to call a program when a cd start playing. I gave it my CDDB script and now I'm building up a nice list of all my cds.
This would be great if my sound card was working. It worked once, sndconfig recognised it (it's a sb16 pci) and it worked fine. Next time I rebooted it stopped working and hasn't worked since. Luckily I can play cds by plugging my speakers into the cdrom drive but this isn't really an ideal situation :(