3 # a horribly funny script that shows how flexible udev can really be
4 # This is to be executed by udev with the following rules:
5 # CALLOUT, BUS="ide", PROGRAM="name_cdrom.pl %M %m", ID="good*", NAME="%1c", SYMLINK="cdrom"
6 # CALLOUT, BUS="scsi", PROGRAM="name_cdrom.pl %M %m", ID="good*", NAME="%1c", SYMLINK="cdrom"
8 # The scsi rule catches USB cdroms and ide-scsi devices.
11 use CDDB_get qw( get_cddb );
15 $dev_node = "/tmp/cd_foo";
17 # following variables just need to be declared if different from defaults
18 $config{CDDB_HOST}="freedb.freedb.org"; # set cddb host
19 $config{CDDB_PORT}=8880; # set cddb port
20 $config{CDDB_MODE}="cddb"; # set cddb mode: cddb or http
21 $config{CD_DEVICE}="$dev_node"; # set cd device
23 # No user interaction, this is a automated script!
29 # create our temp device node to read the cd info from
30 if (system("mknod $dev_node b $major $minor")) {
31 die "bad mknod failed";
35 my %cd=get_cddb(\%config);
37 # remove the dev node we just created
40 # print out our cd name if we have found it
41 unless(defined $cd{title}) {
42 print"bad unknown cdrom\n";
44 print "good $cd{artist}_$cd{title}\n";