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="%2c", SYMLINK="cdrom"
6 # CALLOUT, BUS="scsi", PROGRAM="name_cdrom.pl %M %m", ID="good*", NAME="%2c", 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
31 if (system("mknod $dev_node b $major $minor")) {
32 die "bad mknod failed";
36 my %cd=get_cddb(\%config);
38 # remove the dev node we just created
41 # print out our cd name if we have found it
42 unless(defined $cd{title}) {
43 print"bad unknown cdrom\n";
45 $cd{artist} =~ s/ /_/g;
46 $cd{title} =~ s/ /_/g;
47 print "good $cd{artist}-$cd{title}\n";