VirtualBox

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

Last change on this file since 34575 was 33428, checked in by vboxsync, 14 years ago

Additions/x11/Installer: shell version of the xorg.conf hacking script

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 4.8 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='[Kk][Ee][Yy][Bb][Oo][Aa][Rr][Dd]' # Keyboard
35
36END_SECTION='[Ee][Nn][Dd][Ss][Ee][Cc][Tt][Ii][Oo][Nn]' # EndSection
37
38OPT_XKB='^[ '$tab']*option[ '$tab'][ '$tab']*"xkb'
39
40DRIVER_KBD='^[ '$tab']*[Dd][Rr][Ii][Vv][Ee][Rr][ '$tab'][ '$tab']*'\
41'"\(kbd\|keyboard\)"'
42# ^\s*driver\s+\"(kbd|keyboard)\"
43
44reconfigure()
45{
46 cfg="$1"
47 tmp="$cfg.vbox.tmp"
48 test -w "$cfg" || { echo "$cfg does not exist"; return; }
49 rm -f "$tmp"
50 test ! -e "$tmp" || { echo "Failed to delete $tmp"; return; }
51 touch "$tmp"
52 test -w "$tmp" || { echo "Failed to create $tmp"; return; }
53 xkb_opts="`cat "$cfg" | sed -n -e "/$KBD_SECTION/,/$END_SECTION/p" |
54 grep -i "$OPT_XKB"`"
55 kbd_drv="`cat "$cfg" | sed -n -e "/$KBD_SECTION/,/$END_SECTION/p" |
56 sed -n -e "0,/$DRIVER_KBD/s/$DRIVER_KBD/\\1/p"`"
57 cat > "$tmp" << EOF
58# VirtualBox generated configuration file
59# based on $cfg.
60EOF
61 cat "$cfg" | sed -e "/$ALL_SECTIONS/,/$END_SECTION/s/\\(.*\\)/# \\1/" >> "$tmp"
62 test -n "$kbd_drv" && cat >> "$tmp" << EOF
63Section "InputDevice"
64 Identifier "Keyboard[0]"
65 Driver "$kbd_drv"
66$xkb_opts
67 Option "Protocol" "Standard"
68 Option "CoreKeyboard"
69EndSection
70EOF
71 kbd_layout=""
72 test -n "$kbd_drv" && kbd_layout=' InputDevice "Keyboard[0]" "CoreKeyboard"'
73 test -z "$auto_mouse" -a -z "$new_mouse" && cat >> $tmp << EOF
74
75Section "InputDevice"
76 Identifier "Mouse[1]"
77 Driver "vboxmouse"
78 Option "Buttons" "9"
79 Option "Device" "$old_mouse_dev"
80 Option "Name" "VirtualBox Mouse"
81 Option "Protocol" "explorerps/2"
82 Option "Vendor" "Oracle Corporation"
83 Option "ZAxisMapping" "4 5"
84 Option "CorePointer"
85EndSection
86
87Section "ServerLayout"
88 Identifier "Layout[all]"
89$kbd_layout
90 InputDevice "Mouse[1]" "CorePointer"
91 Option "Clone" "off"
92 Option "Xinerama" "off"
93 Screen "Screen[0]"
94EndSection
95EOF
96
97 test -z "$auto_mouse" -a -n "$new_mouse" &&
98 cat >> "$tmp" << EOF
99
100Section "InputDevice"
101 Driver "mouse"
102 Identifier "Mouse[1]"
103 Option "Buttons" "9"
104 Option "Device" "/dev/input/mice"
105 Option "Name" "VirtualBox Mouse Buttons"
106 Option "Protocol" "explorerps/2"
107 Option "Vendor" "Oracle Corporation"
108 Option "ZAxisMapping" "4 5"
109 Option "CorePointer"
110EndSection
111
112Section "InputDevice"
113 Driver "vboxmouse"
114 Identifier "Mouse[2]"
115 Option "Device" "/dev/vboxguest"
116 Option "Name" "VirtualBox Mouse"
117 Option "Vendor" "Oracle Corporation"
118 Option "SendCoreEvents"
119EndSection
120
121Section "ServerLayout"
122 Identifier "Layout[all]"
123 InputDevice "Keyboard[0]" "CoreKeyboard"
124 InputDevice "Mouse[1]" "CorePointer"
125 InputDevice "Mouse[2]" "SendCoreEvents"
126 Option "Clone" "off"
127 Option "Xinerama" "off"
128 Screen "Screen[0]"
129EndSection
130EOF
131
132 cat >> "$tmp" << EOF
133
134Section "Monitor"
135 Identifier "Monitor[0]"
136 ModelName "VirtualBox Virtual Output"
137 VendorName "Oracle Corporation"
138EndSection
139
140Section "Device"
141 BoardName "VirtualBox Graphics"
142 Driver "vboxvideo"
143 Identifier "Device[0]"
144 VendorName "Oracle Corporation"
145EndSection
146
147Section "Screen"
148 SubSection "Display"
149 Depth 24
150 EndSubSection
151 Device "Device[0]"
152 Identifier "Screen[0]"
153 Monitor "Monitor[0]"
154EndSection
155EOF
156
157 test -n "$no_bak" -o -f "$cfg.vbox" || cp "$cfg" "$cfg.vbox"
158 test -n "$no_bak" || mv "$cfg" "$cfg.bak"
159 mv "$tmp" "$cfg"
160}
161
162while test -n "$1"
163do
164 case "$1" in
165 --autoMouse)
166 auto_mouse=1 ;;
167 --newMouse)
168 new_mouse=1 ;;
169 --noBak)
170 no_bak=1 ;;
171 --nopsaux)
172 old_mouse_dev="/dev/input/mice" ;;
173 *)
174 reconfigure "$1" ;;
175 esac
176 shift
177done
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