Fix typo in the Gentoo initscript.
[fbsplash.git] / core / scripts / bootsplash2fbsplash.in
blob8fe0ca72d7622524ad5a9a709874d7072d552e71
1 #!/usr/bin/perl
3 # bootsplash2fbsplash -- theme conversion utility
4 # (c) 2004-2005 Michal Januszewski <spock@gentoo.org>
6 # Usage: bootsplash2fbsplash [--remove-comments] <theme_name>
9 $path_bp = "@sysconfdir@/bootsplash/";
10 $path_fbspl = "@themedir@";
11 $comments = 1;
12 $theme = "";
14 sub usage
16 print "bootsplash2fbsplash theme converter / splashutils-@PACKAGE_VERSION@\n";
17 print '(c) 2004-2005 Michal Januszewski <spock@gentoo.org>'."\n\n";
18 print "Usage: bootsplash2fbsplash [--remove-comments] <theme_name>\n";
21 my @args = @ARGV;
23 while ($arg = shift @args) {
24 if ($arg eq "--remove-comments") {
25 $comments = 0;
26 } elsif ($arg eq "--bootsplash-path") {
27 $path_bp = shift @args;
28 } elsif ($arg eq "--fbsplash-path") {
29 $path_fbspl = shift @args;
30 } else {
31 $theme = $arg;
35 if ($#ARGV < 0 || $theme eq "") {
36 usage();
37 exit 0;
40 $path_bp =~ s#//#/#g;
41 $path_fbspl =~ s#//#/#g;
43 $cfgroot = "$path_bp/$theme/config";
44 $fbspl_images = "$path_fbspl/$theme/images";
46 opendir(DIR, "$cfgroot") || die "Can't open $cfgroot: $!";
47 @configs = grep { /\.cfg$/ && /bootsplash/ && -f "$cfgroot/$_" } readdir(DIR);
48 closedir(DIR);
50 foreach $cfg (@configs) {
51 $cfg =~ /(\d+)x(\d+)/;
52 $xres = $1;
53 $yres = $2;
55 `mkdir -p $fbspl_images`;
57 open(IN, "<$cfgroot/$cfg");
58 open(OUT, ">$path_fbspl/$theme/${xres}x${yres}.cfg");
60 @known_keyw = ("bgcolor", "tx", "ty", "tw", "th", "text_x", "text_y",
61 "text_size", "text_color");
62 $empty = 0;
64 while ($line = <IN>) {
66 if ($line =~ /^\s*#/ || $line =~ /^\s*$/ || $line =~ /^\s*box /) {
67 goto ok;
68 } elsif ($line =~ /(silent)?jpeg=(.*)$/) {
70 $empty = 0;
72 if ($1 eq "silent") {
73 $t = "silent";
74 } else {
75 $t = "verbose";
78 $t = "$fbspl_images/$t-${xres}x${yres}.jpg";
79 $line = "$1pic=$t\n";
81 if (-e "$2") {
82 `cp -fp -H "$2" "$t"`;
83 } else {
84 print "Error: $2 not found!\n"
86 } else {
87 foreach $key (@known_keyw) {
88 if ($line =~ /^\s*$key=/) {
89 $empty = 0;
90 goto ok;
93 next;
96 ok: if (!$comments) {
97 if ($line =~ /^\s*#/) {
98 next;
99 } elsif ($line =~ /^\s*$/) {
100 if (!$empty) {
101 $empty = 1;
102 } else {
103 next;
108 print OUT $line;
111 $a = `md5sum "$fbspl_images/silent-${xres}x${yres}.jpg" 2>/dev/null | cut -f1 -d' '`;
112 $b = `md5sum "$fbspl_images/verbose-${xres}x${yres}.jpg" 2>/dev/null | cut -f1 -d' '`;
114 chomp $a;
115 chomp $b;
117 if ($a eq $b) {
118 `rm -f "$fbspl_images/silent-${xres}x${yres}.jpg"`;
119 `ln -s "$fbspl_images/verbose-${xres}x${yres}.jpg" "$fbspl_images/silent-${xres}x${yres}.jpg"`;
122 close(OUT);
123 close(IN);
125 print "o Parsed $cfg (${xres}x${yres})\n";