VirtualBox

source: vbox/trunk/src/VBox/Additions/x11/Installer/x11config.sh@ 35102

Last change on this file since 35102 was 35049, checked in by vboxsync, 14 years ago

Additions/x11/Installer: fixed an xorg.conf hacking regression

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 4.9 KB
Line 
1#!/bin/sh
2#
3# Guest Additions X11 config update script
4#
5# Copyright (C) 2006-2010 Oracle Corporation
6#
7# This file is part of VirtualBox Open Source Edition (OSE), as
8# available from http://www.virtualbox.org. This file is free software;
9# you can redistribute it and/or modify it under the terms of the GNU
10# General Public License (GPL) as published by the Free Software
11# Foundation, in version 2 as it comes in the "COPYING" file of the
12# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
13# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
14#
15
16auto_mouse=""
17new_mouse=""
18no_bak=""
19old_mouse_dev="/dev/psaux"
20
21tab=`printf '\t'`
22
23ALL_SECTIONS=\
24'^[ '$tab']*[Ss][Ee][Cc][Tt][Ii][Oo][Nn][ '$tab']*'\
25'"\([Ii][Nn][Pp][Uu][Tt][Dd][Ee][Vv][Ii][Cc][Ee]\|'\
26'[Dd][Ee][Vv][Ii][Cc][Ee]\|'\
27'[Ss][Ee][Rr][Vv][Ee][Rr][Ll][Aa][Yy][Oo][Uu][Tt]\|'\
28'[Ss][Cc][Rr][Ee][Ee][Nn]\|'\
29'[Mm][Oo][Nn][Ii][Tt][Oo][Rr]\|'\
30'[Kk][Ee][Yy][Bb][Oo][Aa][Rr][Dd]\|'\
31'[Pp][Oo][Ii][Nn][Tt][Ee][Rr]\)"'
32# ^\s*Section\s*"(InputDevice|Device|ServerLayout|Screen|Monitor|Keyboard|Pointer)"
33
34KBD_SECTION='^[ '$tab']*[Ss][Ee][Cc][Tt][Ii][Oo][Nn][ '$tab']*"'\
35'[Ii][Nn][Pp][Uu][Tt][Dd][Ee][Vv][Ii][Cc][Ee]"' # ^\s*section\s*\"inputdevice\"
36
37END_SECTION='[Ee][Nn][Dd][Ss][Ee][Cc][Tt][Ii][Oo][Nn]' # EndSection
38
39OPT_XKB='^[ '$tab']*option[ '$tab'][ '$tab']*"xkb'
40
41DRIVER_KBD='^[ '$tab']*[Dd][Rr][Ii][Vv][Ee][Rr][ '$tab'][ '$tab']*'\
42'"\(kbd\|keyboard\)"'
43# ^\s*driver\s+\"(kbd|keyboard)\"
44
45reconfigure()
46{
47 cfg="$1"
48 tmp="$cfg.vbox.tmp"
49 test -w "$cfg" || { echo "$cfg does not exist"; return; }
50 rm -f "$tmp"
51 test ! -e "$tmp" || { echo "Failed to delete $tmp"; return; }
52 touch "$tmp"
53 test -w "$tmp" || { echo "Failed to create $tmp"; return; }
54 xkb_opts="`cat "$cfg" | sed -n -e "/$KBD_SECTION/,/$END_SECTION/p" |
55 grep -i "$OPT_XKB"`"
56 kbd_drv="`cat "$cfg" | sed -n -e "/$KBD_SECTION/,/$END_SECTION/p" |
57 sed -n -e "0,/$DRIVER_KBD/s/$DRIVER_KBD/\\1/p"`"
58 cat > "$tmp" << EOF
59# VirtualBox generated configuration file
60# based on $cfg.
61EOF
62 cat "$cfg" | sed -e "/$ALL_SECTIONS/,/$END_SECTION/s/\\(.*\\)/# \\1/" >> "$tmp"
63 test -n "$kbd_drv" && cat >> "$tmp" << EOF
64Section "InputDevice"
65 Identifier "Keyboard[0]"
66 Driver "$kbd_drv"
67$xkb_opts
68 Option "Protocol" "Standard"
69 Option "CoreKeyboard"
70EndSection
71EOF
72 kbd_layout=""
73 test -n "$kbd_drv" && kbd_layout=' InputDevice "Keyboard[0]" "CoreKeyboard"'
74 test -z "$auto_mouse" -a -z "$new_mouse" && cat >> $tmp << EOF
75
76Section "InputDevice"
77 Identifier "Mouse[1]"
78 Driver "vboxmouse"
79 Option "Buttons" "9"
80 Option "Device" "$old_mouse_dev"
81 Option "Name" "VirtualBox Mouse"
82 Option "Protocol" "explorerps/2"
83 Option "Vendor" "Oracle Corporation"
84 Option "ZAxisMapping" "4 5"
85 Option "CorePointer"
86EndSection
87
88Section "ServerLayout"
89 Identifier "Layout[all]"
90$kbd_layout
91 InputDevice "Mouse[1]" "CorePointer"
92 Option "Clone" "off"
93 Option "Xinerama" "off"
94 Screen "Screen[0]"
95EndSection
96EOF
97
98 test -z "$auto_mouse" -a -n "$new_mouse" &&
99 cat >> "$tmp" << EOF
100
101Section "InputDevice"
102 Driver "mouse"
103 Identifier "Mouse[1]"
104 Option "Buttons" "9"
105 Option "Device" "/dev/input/mice"
106 Option "Name" "VirtualBox Mouse Buttons"
107 Option "Protocol" "explorerps/2"
108 Option "Vendor" "Oracle Corporation"
109 Option "ZAxisMapping" "4 5"
110 Option "CorePointer"
111EndSection
112
113Section "InputDevice"
114 Driver "vboxmouse"
115 Identifier "Mouse[2]"
116 Option "Device" "/dev/vboxguest"
117 Option "Name" "VirtualBox Mouse"
118 Option "Vendor" "Oracle Corporation"
119 Option "SendCoreEvents"
120EndSection
121
122Section "ServerLayout"
123 Identifier "Layout[all]"
124 InputDevice "Keyboard[0]" "CoreKeyboard"
125 InputDevice "Mouse[1]" "CorePointer"
126 InputDevice "Mouse[2]" "SendCoreEvents"
127 Option "Clone" "off"
128 Option "Xinerama" "off"
129 Screen "Screen[0]"
130EndSection
131EOF
132
133 cat >> "$tmp" << EOF
134
135Section "Monitor"
136 Identifier "Monitor[0]"
137 ModelName "VirtualBox Virtual Output"
138 VendorName "Oracle Corporation"
139EndSection
140
141Section "Device"
142 BoardName "VirtualBox Graphics"
143 Driver "vboxvideo"
144 Identifier "Device[0]"
145 VendorName "Oracle Corporation"
146EndSection
147
148Section "Screen"
149 SubSection "Display"
150 Depth 24
151 EndSubSection
152 Device "Device[0]"
153 Identifier "Screen[0]"
154 Monitor "Monitor[0]"
155EndSection
156EOF
157
158 test -n "$no_bak" -o -f "$cfg.vbox" || cp "$cfg" "$cfg.vbox"
159 test -n "$no_bak" || mv "$cfg" "$cfg.bak"
160 mv "$tmp" "$cfg"
161}
162
163while test -n "$1"
164do
165 case "$1" in
166 --autoMouse)
167 auto_mouse=1 ;;
168 --newMouse)
169 new_mouse=1 ;;
170 --noBak)
171 no_bak=1 ;;
172 --nopsaux)
173 old_mouse_dev="/dev/input/mice" ;;
174 *)
175 reconfigure "$1" ;;
176 esac
177 shift
178done
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