chiark / gitweb /
5e696f33ae31bff2591c257d4f3d4940d5f9c6c8
[elogind.git] / extras / name_cdrom.pl
1 #!/usr/bin/perl
2
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 #
6 # KERNEL="hd*[!0-9]|sr*", PROGRAM="name_cdrom.pl $tempnode", SYMLINK+="%c"
7
8 use strict;
9 use warnings;
10
11 use CDDB_get qw(get_cddb);
12
13 # following variables just need to be declared if different from defaults
14 my %config;
15 $config{'CDDB_HOST'} = "freedb.freedb.org";     # set cddb host
16 $config{'CDDB_PORT'} = 8880;                    # set cddb port
17 $config{'CDDB_MODE'} = "cddb";                  # set cddb mode: cddb or http
18 $config{'CD_DEVICE'} = $ARGV[0];                # set cd device
19 $config{'input'} = 0;                           # no user interaction
20
21 my %cd = get_cddb(\%config);
22
23 if (!defined $cd{title}) {
24         exit 1;
25 }
26
27 # print out our cd name
28 $cd{artist} =~ s/ /_/g;
29 $cd{title} =~ s/ /_/g;
30 print "$cd{artist}-$cd{title}\n";
31
32 exit 0;