VirtualBox

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

Last change on this file since 68495 was 50312, checked in by vboxsync, 11 years ago

Additions/linux/installer: support VMSVGA.

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