2004-01-06 10:11:53 +01:00
|
|
|
#!/usr/bin/perl
|
|
|
|
|
2005-11-25 18:50:42 +01:00
|
|
|
# Horrible but funny script that shows how flexible udev can really be
|
|
|
|
# This is to be executed by udev with the following rule:
|
|
|
|
# KERNEL="hd*[!0-9]|sr*", PROGRAM="name_cdrom.pl $tempnode", SYMLINK+="%c"
|
2004-01-06 10:11:53 +01:00
|
|
|
|
2004-01-14 03:34:38 +01:00
|
|
|
use strict;
|
|
|
|
use warnings;
|
2004-01-06 10:11:53 +01:00
|
|
|
|
2005-09-08 12:24:18 +02:00
|
|
|
use CDDB_get qw(get_cddb);
|
2004-01-06 10:11:53 +01:00
|
|
|
|
|
|
|
# following variables just need to be declared if different from defaults
|
2004-01-14 03:34:38 +01:00
|
|
|
my %config;
|
2005-09-08 12:24:18 +02:00
|
|
|
$config{'CDDB_HOST'} = "freedb.freedb.org"; # set cddb host
|
|
|
|
$config{'CDDB_PORT'} = 8880; # set cddb port
|
|
|
|
$config{'CDDB_MODE'} = "cddb"; # set cddb mode: cddb or http
|
|
|
|
$config{'CD_DEVICE'} = $ARGV[0]; # set cd device
|
|
|
|
$config{'input'} = 0; # no user interaction
|
2004-01-06 10:11:53 +01:00
|
|
|
|
2005-09-08 12:24:18 +02:00
|
|
|
my %cd = get_cddb(\%config);
|
2004-01-06 10:11:53 +01:00
|
|
|
|
2005-09-08 12:24:18 +02:00
|
|
|
if (!defined $cd{title}) {
|
|
|
|
exit 1;
|
2004-01-10 10:04:13 +01:00
|
|
|
}
|
2004-01-06 10:11:53 +01:00
|
|
|
|
2005-09-08 12:24:18 +02:00
|
|
|
# print out our cd name
|
|
|
|
$cd{artist} =~ s/ /_/g;
|
|
|
|
$cd{title} =~ s/ /_/g;
|
|
|
|
print "$cd{artist}-$cd{title}\n";
|
2004-01-06 10:11:53 +01:00
|
|
|
|
2005-09-08 12:24:18 +02:00
|
|
|
exit 0;
|