summaryrefslogtreecommitdiffstats
path: root/grub-gfxmenu
diff options
context:
space:
mode:
Diffstat (limited to 'grub-gfxmenu')
-rwxr-xr-xgrub-gfxmenu72
1 files changed, 72 insertions, 0 deletions
diff --git a/grub-gfxmenu b/grub-gfxmenu
new file mode 100755
index 0000000..28b0efe
--- /dev/null
+++ b/grub-gfxmenu
@@ -0,0 +1,72 @@
+#!/usr/bin/perl
+
+use Getopt::Long;
+
+my $gfxmenu = '/boot/gfxmenu';
+
+my %options = (
+ "lang=s" => \ (my $lang),
+ "update-theme" => \ (my $update_theme),
+ "update-gfxmenu" => \ (my $update_gfxmenu),
+ );
+
+GetOptions(%options) && @ARGV == 0 && ($lang || $update_theme || $update_gfxmenu) or usage();
+
+if ($update_gfxmenu) {
+ $update_theme = 1;
+ $lang ||= get_lang();
+ sys('cp', '/usr/share/gfxboot/themes/Mandriva/boot/message', $gfxmenu);
+}
+if ($lang) {
+ set_lang($lang);
+}
+if ($update_theme) {
+ set_theme();
+}
+
+sub usage {
+ die "grub-gfxmenu [--lang <lang>] [--update-theme] [--update-gfxmenu]\n";
+}
+
+sub set_theme() {
+ my $background_dir = '/usr/share/gfxboot/themes/current';
+
+ #checking
+ -f "$background_dir/back.jpg" or return;
+ remove_file('back.jpg');
+ sys("echo back.jpg | (cd $background_dir ; cpio -o --quiet -O $gfxmenu --append)");
+}
+
+sub remove_file {
+ my ($file) = @_;
+ sys("cpio-filter --in-place --exclude $file $gfxmenu");
+}
+
+sub get_lang() {
+ require Archive::Cpio;
+
+ my $cpio = Archive::Cpio->new;
+ $cpio->read($gfxmenu);
+ my $e = $cpio->get_file('lang') or return;
+ my $lang = $e->{data};
+ chomp $lang;
+ $lang;
+}
+
+sub set_lang {
+ my ($lang) = @_;
+
+ require Archive::Cpio;
+
+ my $cpio = Archive::Cpio->new;
+ $cpio->read($gfxmenu);
+ if (my $e = $cpio->get_file('lang')) {
+ $e->{data} = "$lang\n";
+ } else {
+ $cpio->add_data('lang', "$lang\n");
+ }
+ $cpio->write($gfxmenu);
+}
+
+sub system_verbose { print join(' ', @_), "\n"; system(@_) }
+sub sys { system(@_); $? and die }