diff options
Diffstat (limited to 'perl-install/bootsplash.pm')
-rw-r--r-- | perl-install/bootsplash.pm | 110 |
1 files changed, 98 insertions, 12 deletions
diff --git a/perl-install/bootsplash.pm b/perl-install/bootsplash.pm index fe4af57ac..86f2e590e 100644 --- a/perl-install/bootsplash.pm +++ b/perl-install/bootsplash.pm @@ -4,10 +4,11 @@ use common; my $themes_dir = "$::prefix/usr/share/bootsplash/themes/"; my $sysconfig_file = '$::prefix/etc/sysconfig/bootsplash'; +my $bootsplash_scripts = "$::prefix/usr/share/bootsplash/scripts"; my $default_theme = 'Mandrivalinux'; our $default_thumbnail = '/usr/share/libDrakX/pixmaps/nosplash_thumb.png'; -sub read_theme_config { +sub themes_read_sysconfig { my ($res) = @_; my %theme = ( name => $default_theme, @@ -18,40 +19,59 @@ sub read_theme_config { local $_; foreach (cat_($sysconfig_file)) { /^SPLASH=no/ and $theme{enabled} = 0; - /^THEME=(.*)/ && -f get_theme_image($1, $res) and $theme{name} = $1; + /^THEME=(.*)/ && -f theme_get_image_for_resolution($1, $res) and $theme{name} = $1; /^LOGO_CONSOLE=(.*)/ and $theme{keep_logo} = $1 ne "no"; } } \%theme; } -sub get_theme_image { + +sub theme_get_image_for_resolution { my ($theme, $res) = @_; $themes_dir . $theme . '/images/bootsplash-' . $res . ".jpg"; } -sub list_themes { +sub theme_get_config_for_resolution { + my ($theme, $res) = @_; + $themes_dir . $theme . '/cfg/bootsplash-' . $res . ".cfg"; +} + +sub theme_get_global_config { + my ($theme) = @_; + $themes_dir . $theme . '/cfg/global.config'; +} + + +sub theme_exists_for_resolution { + my ($theme, $res) = @_; + -f theme_get_image_for_resolution($theme, $res); +} + +sub themes_list() { + grep { !/^\./ && -d $themes_dir } sort(all($themes_dir)); +} + +sub themes_list_for_resolution { my ($res) = @_; - grep { - !/^\./ && -d $themes_dir . $_ && -f get_theme_image($_, $res); - } sort(all($themes_dir)); + grep { theme_exists_for_resolution($_, $res) } themes_list(); } -sub switch_theme { +sub switch { my ($theme) = @_; if ($::testing) { print "enabling bootsplash theme $theme\n"; } else { #- theme scripts will update SPLASH value in sysconfig file - system("$::prefix/usr/share/bootsplash/scripts/switch-themes", $theme); + system($bootsplash_scripts . '/switch-themes', $theme); } } -sub remove_theme() { +sub remove() { if ($::testing) { - print "disabling bootplash theme\n"; + print "disabling bootsplash theme\n"; } else { - system("$::prefix/usr/share/bootsplash/scripts/remove-theme"); + system($bootsplash_scripts . '/remove-theme'); } } @@ -61,4 +81,70 @@ sub set_logo_console { substInFile { s/^LOGO_CONSOLE=.*/LOGO_CONSOLE=$logo_console/ } $sysconfig_file; } +sub theme_set_image_for_resolution { + my ($name, $source_image, $res) = @_; + my $dest_image = theme_get_image_for_resolution($name, $res); + system('convert', '-scale', $res, $source_image, $dest_image); + system($bootsplash_scripts . '/rewritejpeg', $dest_image); +} + +sub theme_read_config_for_resolution { + my ($theme, $res) = @_; + getVarsFromSh(theme_get_config_for_resolution($theme, $res)); +} + +sub theme_write_config_for_resolution { + my ($name, $res, $conf) = @_; + + my $global_config = theme_get_global_config($name); + my $config = theme_get_config_for_resolution($name, $res); + my $theme_config_dir = $themes_dir . $name . '/cfg/'; + -d $theme_config_dir or mkdir_p($theme_config_dir); + + output($config, + qq(# This is the configuration file for the $res bootsplash picture +# this file is necessary to specify the coordinates of the text box on the +# splash screen. + +# tx is the x coordinate of the text window in characters. default is 24 +# multiply width font width for coordinate in pixels. +tx=$conf->{tx} + +# ty is the y coordinate of the text window in characters. default is 14 +ty=$conf->{ty} + +# tw is the width of the text window in characters. default is 130 +# note: this should at least be 80 as on the standard linux text console +tw=$conf->{tw} + +# th is the height of the text window in characters. default is 44 +# NOTE: this should at least be 25 as on the standard linux text console +th=$conf->{th} + +# px is the progress bar x coordinate of its upper left corner +px=$conf->{px} + +# py is the progress bar y coordinate of its upper left corner +py=$conf->{py} + +# pw is the with of the progress bar +pw=$conf->{pw} + +# ph is the height of the progress bar +ph=$conf->{ph} + +# pc is the color of the progress bar +pc=$conf->{pc} +)); + + output($global_config, + qq(# Display logo on console. +LOGO_CONSOLE=$conf->{logo} + +# Make kernel message quiet by default. +QUIET=$conf->{quiet} +)); +} + + 1; |