chiark / gitweb /
replace binary firmware helper with shell script
[elogind.git] / extras / name_cdrom.pl
1 #!/usr/bin/perl
2
3 # Horrible but funny script that shows how flexible udev can really be
4 # This is to be executed by udev with the following rule:
5 #   KERNEL="hd*[!0-9]|sr*", PROGRAM="name_cdrom.pl $tempnode", SYMLINK+="%c"
6
7 use strict;
8 use warnings;
9
10 use CDDB_get qw(get_cddb);
11
12 # following variables just need to be declared if different from defaults
13 my %config;
14 $config{'CDDB_HOST'} = "freedb.freedb.org";     # set cddb host
15 $config{'CDDB_PORT'} = 8880;                    # set cddb port
16 $config{'CDDB_MODE'} = "cddb";                  # set cddb mode: cddb or http
17 $config{'CD_DEVICE'} = $ARGV[0];                # set cd device
18 $config{'input'} = 0;                           # no user interaction
19
20 my %cd = get_cddb(\%config);
21
22 if (!defined $cd{title}) {
23         exit 1;
24 }
25
26 # print out our cd name
27 $cd{artist} =~ s/ /_/g;
28 $cd{title} =~ s/ /_/g;
29 print "$cd{artist}-$cd{title}\n";
30
31 exit 0;