summaryrefslogtreecommitdiffstats
path: root/perl-install/bootsplash.pm
blob: fe4af57ac24c10eb9a913880dbcc19098608527d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package bootsplash;

use common;

my $themes_dir = "$::prefix/usr/share/bootsplash/themes/";
my $sysconfig_file = '$::prefix/etc/sysconfig/bootsplash';
my $default_theme = 'Mandrivalinux';
our $default_thumbnail = '/usr/share/libDrakX/pixmaps/nosplash_thumb.png';

sub read_theme_config {
    my ($res) = @_;
    my %theme = (
                 name => $default_theme,
                 enabled => 1,
                 keep_logo => 1
                );
    if (-r $sysconfig_file) {
        local $_;
        foreach (cat_($sysconfig_file)) {
            /^SPLASH=no/ and $theme{enabled} = 0;
            /^THEME=(.*)/ && -f get_theme_image($1, $res) and $theme{name} = $1;
            /^LOGO_CONSOLE=(.*)/ and $theme{keep_logo} = $1 ne "no";
        }
    }
    \%theme;
}

sub get_theme_image {
    my ($theme, $res) = @_;
    $themes_dir . $theme . '/images/bootsplash-' . $res . ".jpg";
}

sub list_themes {
    my ($res) = @_;
    grep {
        !/^\./ && -d $themes_dir . $_ && -f get_theme_image($_, $res);
    } sort(all($themes_dir));
}

sub switch_theme {
    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);
    }
}

sub remove_theme() {
    if ($::testing) {
        print "disabling bootplash theme\n";
    } else {
        system("$::prefix/usr/share/bootsplash/scripts/remove-theme");
    }
}

sub set_logo_console {
    my ($keep_logo) = @_;
    my $logo_console = $keep_logo ? 'theme' : 'no';
    substInFile { s/^LOGO_CONSOLE=.*/LOGO_CONSOLE=$logo_console/ } $sysconfig_file;
}

1;