VirtualBox

source: vbox/trunk/src/VBox/Additions/x11/Installer/x11config-new.pl@ 27153

Last change on this file since 27153 was 26427, checked in by vboxsync, 15 years ago

tabs

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 5.7 KB
Line 
1#!/usr/bin/perl -w
2#
3# Sun VirtualBox
4#
5# Guest Additions X11 config update script
6#
7# Copyright (C) 2006-2009 Sun Microsystems, Inc.
8#
9# This file is part of VirtualBox Open Source Edition (OSE), as
10# available from http://www.virtualbox.org. This file is free software;
11# you can redistribute it and/or modify it under the terms of the GNU
12# General Public License (GPL) as published by the Free Software
13# Foundation, in version 2 as it comes in the "COPYING" file of the
14# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16#
17# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18# Clara, CA 95054 USA or visit http://www.sun.com if you need
19# additional information or have any questions.
20#
21
22my $auto_mouse = 0;
23my $new_mouse = 0;
24my $no_bak = 0;
25my $old_mouse_dev = "/dev/psaux";
26
27foreach $arg (@ARGV)
28{
29 if (lc($arg) eq "--autoMouse")
30 {
31 $auto_mouse = 1;
32 }
33 elsif (lc($arg) eq "--newmouse")
34 {
35 $new_mouse = 1;
36 }
37 elsif (lc($arg) eq "--nobak")
38 {
39 $no_bak = 1;
40 }
41 elsif (lc($arg) eq "--nopsaux")
42 {
43 $old_mouse_dev = "/dev/input/mice";
44 }
45 else
46 {
47 my $cfg = $arg;
48 my $CFG;
49 my $xkbopts = "";
50 my $kb_driver = "";
51 my $layout_kb = "";
52 if (open(CFG, $cfg))
53 {
54 my $TMP;
55 my $temp = $cfg.".vbox.tmp";
56 open(TMP, ">$temp") or die "Can't create $TMP: $!\n";
57
58 my $in_section = 0;
59 print TMP "# VirtualBox generated configuration file\n";
60 print TMP "# based on $cfg.\n";
61
62 while (defined ($line = <CFG>))
63 {
64 if ($line =~ /^\s*Section\s*"([a-zA-Z]+)"/i)
65 {
66 my $section = lc($1);
67 if ( ($section eq "inputdevice")
68 || ($section eq "device")
69 || ($section eq "serverlayout")
70 || ($section eq "screen")
71 || ($section eq "monitor")
72 || ($section eq "keyboard")
73 || ($section eq "pointer"))
74 {
75 $in_section = 1;
76 }
77 } else {
78 if ($line =~ /^\s*EndSection/i)
79 {
80 $line = "# " . $line unless $in_section eq 0;
81 $in_section = 0;
82 }
83 }
84
85 if ($in_section)
86 {
87 # Remember XKB options
88 if ($line =~ /^\s*option\s+\"xkb/i)
89 {
90 $xkbopts = $xkbopts . $line;
91 }
92 # If we find a keyboard driver, remember it
93 if ($line =~ /^\s*driver\s+\"(kbd|keyboard)\"/i)
94 {
95 $kb_driver = $1;
96 }
97 $line = "# " . $line;
98 }
99 print TMP $line;
100 }
101
102 if ($kb_driver ne "")
103 {
104 print TMP <<EOF;
105Section "InputDevice"
106 Identifier "Keyboard[0]"
107 Driver "$kb_driver"
108$xkbopts Option "Protocol" "Standard"
109 Option "CoreKeyboard"
110EndSection
111EOF
112 $layout_kb = " InputDevice \"Keyboard[0]\" \"CoreKeyboard\"\n"
113 }
114
115 if (!$auto_mouse && !$new_mouse) {
116 print TMP <<EOF;
117
118Section "InputDevice"
119 Identifier "Mouse[1]"
120 Driver "vboxmouse"
121 Option "Buttons" "9"
122 Option "Device" "$old_mouse_dev"
123 Option "Name" "VirtualBox Mouse"
124 Option "Protocol" "explorerps/2"
125 Option "Vendor" "Sun Microsystems Inc"
126 Option "ZAxisMapping" "4 5"
127 Option "CorePointer"
128EndSection
129
130Section "ServerLayout"
131 Identifier "Layout[all]"
132$layout_kb InputDevice "Mouse[1]" "CorePointer"
133 Option "Clone" "off"
134 Option "Xinerama" "off"
135 Screen "Screen[0]"
136EndSection
137EOF
138 }
139
140 if (!$auto_mouse && $new_mouse) {
141 print TMP <<EOF;
142
143Section "InputDevice"
144 Driver "mouse"
145 Identifier "Mouse[1]"
146 Option "Buttons" "9"
147 Option "Device" "/dev/input/mice"
148 Option "Name" "VirtualBox Mouse Buttons"
149 Option "Protocol" "explorerps/2"
150 Option "Vendor" "Sun Microsystems Inc"
151 Option "ZAxisMapping" "4 5"
152 Option "CorePointer"
153EndSection
154
155Section "InputDevice"
156 Driver "vboxmouse"
157 Identifier "Mouse[2]"
158 Option "Device" "/dev/vboxguest"
159 Option "Name" "VirtualBox Mouse"
160 Option "Vendor" "Sun Microsystems Inc"
161 Option "SendCoreEvents"
162EndSection
163
164Section "ServerLayout"
165 Identifier "Layout[all]"
166 InputDevice "Keyboard[0]" "CoreKeyboard"
167 InputDevice "Mouse[1]" "CorePointer"
168 InputDevice "Mouse[2]" "SendCoreEvents"
169 Option "Clone" "off"
170 Option "Xinerama" "off"
171 Screen "Screen[0]"
172EndSection
173EOF
174 }
175
176 print TMP <<EOF;
177
178Section "Monitor"
179 Identifier "Monitor[0]"
180 ModelName "VirtualBox Virtual Output"
181 VendorName "Sun Microsystems Inc"
182EndSection
183
184Section "Device"
185 BoardName "VirtualBox Graphics"
186 Driver "vboxvideo"
187 Identifier "Device[0]"
188 VendorName "Sun Microsystems Inc"
189EndSection
190
191Section "Screen"
192 SubSection "Display"
193 Depth 24
194 EndSubSection
195 Device "Device[0]"
196 Identifier "Screen[0]"
197 Monitor "Monitor[0]"
198EndSection
199EOF
200 close(TMP);
201
202 system("cp", $cfg, $cfg.".vbox") unless
203 ($no_bak eq 1 || -e $cfg.".vbox");
204 rename $cfg, $cfg.".bak" unless $no_bak eq 1;
205 rename $temp, $cfg;
206 }
207 }
208}
209exit 0
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette