VirtualBox

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

Last change on this file since 25389 was 25174, checked in by vboxsync, 15 years ago

Additions/linux/installer: more xorg.conf hacking fixes - some old guests do not like /dev/input/mice

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 5.6 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 $use_hal = 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 "--usehal")
30 {
31 $use_hal = 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 if (open(CFG, $cfg))
52 {
53 my $TMP;
54 my $temp = $cfg.".vbox.tmp";
55 open(TMP, ">$temp") or die "Can't create $TMP: $!\n";
56
57 my $in_section = 0;
58 print TMP "# VirtualBox generated configuration file\n";
59 print TMP "# based on $cfg.\n";
60
61 while (defined ($line = <CFG>))
62 {
63 if ($line =~ /^\s*Section\s*"([a-zA-Z]+)"/i)
64 {
65 my $section = lc($1);
66 if ( ($section eq "inputdevice")
67 || ($section eq "device")
68 || ($section eq "serverlayout")
69 || ($section eq "screen")
70 || ($section eq "monitor")
71 || ($section eq "keyboard")
72 || ($section eq "pointer"))
73 {
74 $in_section = 1;
75 }
76 } else {
77 if ($line =~ /^\s*EndSection/i)
78 {
79 $line = "# " . $line unless $in_section eq 0;
80 $in_section = 0;
81 }
82 }
83
84 if ($in_section)
85 {
86 # Remember XKB options
87 if ($line =~ /^\s*option\s+\"xkb/i)
88 {
89 $xkbopts = $xkbopts . $line;
90 }
91 # If we find a keyboard driver, remember it
92 if ($line =~ /^\s*driver\s+\"(kbd|keyboard)\"/i)
93 {
94 $kb_driver = $1;
95 }
96 $line = "# " . $line;
97 }
98 print TMP $line;
99 }
100
101 if ($kb_driver ne "")
102 {
103 print TMP <<EOF;
104Section "InputDevice"
105 Identifier "Keyboard[0]"
106 Driver "$kb_driver"
107$xkbopts Option "Protocol" "Standard"
108 Option "CoreKeyboard"
109EndSection
110EOF
111 }
112
113 if (!$use_hal && !$new_mouse) {
114 print TMP <<EOF;
115
116Section "InputDevice"
117 Identifier "Mouse[1]"
118 Driver "vboxmouse"
119 Option "Buttons" "9"
120 Option "Device" "$old_mouse_dev"
121 Option "Name" "VirtualBox Mouse"
122 Option "Protocol" "explorerps/2"
123 Option "Vendor" "Sun Microsystems Inc"
124 Option "ZAxisMapping" "4 5"
125 Option "CorePointer"
126EndSection
127
128Section "ServerLayout"
129 Identifier "Layout[all]"
130 InputDevice "Keyboard[0]" "CoreKeyboard"
131 InputDevice "Mouse[1]" "CorePointer"
132 Option "Clone" "off"
133 Option "Xinerama" "off"
134 Screen "Screen[0]"
135EndSection
136EOF
137 }
138
139 if (!$use_hal && $new_mouse) {
140 print TMP <<EOF;
141
142Section "InputDevice"
143 Driver "mouse"
144 Identifier "Mouse[1]"
145 Option "Buttons" "9"
146 Option "Device" "/dev/input/mice"
147 Option "Name" "VirtualBox Mouse Buttons"
148 Option "Protocol" "explorerps/2"
149 Option "Vendor" "Sun Microsystems Inc"
150 Option "ZAxisMapping" "4 5"
151 Option "CorePointer"
152EndSection
153
154Section "InputDevice"
155 Driver "vboxmouse"
156 Identifier "Mouse[2]"
157 Option "Device" "/dev/vboxguest"
158 Option "Name" "VirtualBox Mouse"
159 Option "Vendor" "Sun Microsystems Inc"
160 Option "SendCoreEvents"
161EndSection
162
163Section "ServerLayout"
164 Identifier "Layout[all]"
165 InputDevice "Mouse[1]" "CorePointer"
166 InputDevice "Mouse[2]" "SendCoreEvents"
167 Option "Clone" "off"
168 Option "Xinerama" "off"
169 Screen "Screen[0]"
170EndSection
171EOF
172 }
173
174 print TMP <<EOF;
175
176Section "Monitor"
177 Identifier "Monitor[0]"
178 ModelName "VirtualBox Virtual Output"
179 VendorName "Sun Microsystems Inc"
180EndSection
181
182Section "Device"
183 BoardName "VirtualBox Graphics"
184 Driver "vboxvideo"
185 Identifier "Device[0]"
186 VendorName "Sun Microsystems Inc"
187EndSection
188
189Section "Screen"
190 SubSection "Display"
191 Depth 24
192 EndSubSection
193 Device "Device[0]"
194 Identifier "Screen[0]"
195 Monitor "Monitor[0]"
196EndSection
197EOF
198 close(TMP);
199
200 system("cp", $cfg, $cfg.".vbox") unless
201 ($no_bak eq 1 || -e $cfg.".vbox");
202 rename $cfg, $cfg.".bak" unless $no_bak eq 1;
203 rename $temp, $cfg;
204 }
205 }
206}
207exit 0
Note: See TracBrowser for help on using the repository browser.

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