#!/usr/bin/perl -w # # Sun VirtualBox # # Guest Additions X11 config update script # # Copyright (C) 2006-2009 Sun Microsystems, Inc. # # This file is part of VirtualBox Open Source Edition (OSE), as # available from http://www.virtualbox.org. This file is free software; # you can redistribute it and/or modify it under the terms of the GNU # General Public License (GPL) as published by the Free Software # Foundation, in version 2 as it comes in the "COPYING" file of the # VirtualBox OSE distribution. VirtualBox OSE is distributed in the # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. # # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa # Clara, CA 95054 USA or visit http://www.sun.com if you need # additional information or have any questions. # my $use_hal = 0; my $new_mouse = 0; my $no_bak = 0; foreach $arg (@ARGV) { if (lc($arg) eq "--usehal") { $use_hal = 1; } elsif (lc($arg) eq "--newmouse") { $new_mouse = 1; } elsif (lc($arg) eq "--nobak") { $no_bak = 1; } else { my $cfg = $arg; my $CFG; my $xkbopts = ""; my $kb_driver = ""; if (open(CFG, $cfg)) { my $TMP; my $temp = $cfg.".vbox.tmp"; open(TMP, ">$temp") or die "Can't create $TMP: $!\n"; my $in_section = 0; print TMP "# VirtualBox generated configuration file\n"; print TMP "# based on $cfg.\n"; while (defined ($line = )) { if ($line =~ /^\s*Section\s*"([a-zA-Z]+)"/i) { my $section = lc($1); if ( ($section eq "inputdevice") || ($section eq "device") || ($section eq "serverlayout") || ($section eq "screen") || ($section eq "monitor") || ($section eq "keyboard") || ($section eq "pointer")) { $in_section = 1; } } else { if ($line =~ /^\s*EndSection/i) { $line = "# " . $line unless $in_section eq 0; $in_section = 0; } } if ($in_section) { # Remember XKB options if ($line =~ /^\s*option\s+\"xkb/i) { $xkbopts = $xkbopts . $line; } # If we find a keyboard driver, remember it if ($line =~ /^\s*driver\s+\"(kbd|keyboard)\"/i) { $kb_driver = $1; } $line = "# " . $line; } print TMP $line; } if ($kb_driver ne "") { print TMP <