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 # KERNEL="[hs]d[a-z]", PROGRAM="name_cdrom.pl %M %m", NAME="%c{1}", SYMLINK="cdrom"
10 use CDDB_get qw( get_cddb );
12 my $dev_node = "/tmp/cd_foo";
14 # following variables just need to be declared if different from defaults
16 $config{CDDB_HOST}="freedb.freedb.org"; # set cddb host
17 $config{CDDB_PORT}=8880; # set cddb port
18 $config{CDDB_MODE}="cddb"; # set cddb mode: cddb or http
19 $config{CD_DEVICE}="$dev_node"; # set cd device
21 # No user interaction, this is a automated script!
27 # create our temp device node to read the cd info from
29 if (system("mknod $dev_node b $major $minor")) {
30 die "bad mknod failed";
34 my %cd=get_cddb(\%config);
36 # remove the dev node we just created
39 # print out our cd name if we have found it or skip rule by nonzero exit
40 if (defined $cd{title}) {
41 $cd{artist} =~ s/ /_/g;
42 $cd{title} =~ s/ /_/g;
43 print "$cd{artist}-$cd{title}\n";