VirtualBox

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

Last change on this file since 47631 was 46563, checked in by vboxsync, 12 years ago

Additions/linux: cleaned up xorg.conf set-up and fixed a case when no original file was present.

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 4.3 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"
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 test -z "${kbd_drv}" && test -z "${auto_keyboard}" && kbd_drv=keyboard
59 cat > "$tmp" << EOF
60# VirtualBox generated configuration file
61# based on $cfg.
62EOF
63 cat "$cfg" | sed -e "/$ALL_SECTIONS/,/$END_SECTION/s/\\(.*\\)/# \\1/" >> "$tmp"
64 test -n "$kbd_drv" && cat >> "$tmp" << EOF
65Section "InputDevice"
66 Identifier "Keyboard[0]"
67 Driver "$kbd_drv"
68$xkb_opts
69 Option "Protocol" "Standard"
70 Option "CoreKeyboard"
71EndSection
72EOF
73 kbd_line=""
74 test -n "$kbd_drv" && kbd_line=' InputDevice "Keyboard[0]" "CoreKeyboard"'
75 test -z "$auto_mouse" &&
76 cat >> "$tmp" << EOF
77
78Section "InputDevice"
79 Driver "mouse"
80 Identifier "Mouse[1]"
81 Option "Buttons" "9"
82 Option "Device" "$old_mouse_dev"
83 Option "Name" "VirtualBox Mouse Buttons"
84 Option "Protocol" "explorerps/2"
85 Option "Vendor" "Oracle Corporation"
86 Option "ZAxisMapping" "4 5"
87 Option "CorePointer"
88EndSection
89
90Section "InputDevice"
91 Driver "vboxmouse"
92 Identifier "Mouse[2]"
93 Option "Device" "/dev/vboxguest"
94 Option "Name" "VirtualBox Mouse"
95 Option "Vendor" "Oracle Corporation"
96 Option "SendCoreEvents"
97EndSection
98
99Section "ServerLayout"
100 Identifier "Layout[all]"
101${kbd_line}
102 InputDevice "Mouse[1]" "CorePointer"
103 InputDevice "Mouse[2]" "SendCoreEvents"
104 Option "Clone" "off"
105 Option "Xinerama" "off"
106 Screen "Screen[0]"
107EndSection
108EOF
109
110 cat >> "$tmp" << EOF
111
112Section "Monitor"
113 Identifier "Monitor[0]"
114 ModelName "VirtualBox Virtual Output"
115 VendorName "Oracle Corporation"
116EndSection
117
118Section "Device"
119 BoardName "VirtualBox Graphics"
120 Driver "vboxvideo"
121 Identifier "Device[0]"
122 VendorName "Oracle Corporation"
123EndSection
124
125Section "Screen"
126 SubSection "Display"
127 Depth 24
128 EndSubSection
129 Device "Device[0]"
130 Identifier "Screen[0]"
131 Monitor "Monitor[0]"
132EndSection
133EOF
134
135 test -n "$no_bak" -o -f "$cfg.vbox" || cp "$cfg" "$cfg.vbox"
136 test -n "$no_bak" || mv "$cfg" "$cfg.bak"
137 mv "$tmp" "$cfg"
138}
139
140while test -n "$1"
141do
142 case "$1" in
143 --autoMouse)
144 auto_mouse=1 ;;
145 --autoKeyboard)
146 auto_keyboard=1 ;;
147 --noBak)
148 no_bak=1 ;;
149 --nopsaux)
150 old_mouse_dev="/dev/input/mice" ;;
151 *)
152 reconfigure "$1" ;;
153 esac
154 shift
155done
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