VirtualBox

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

Last change on this file since 93115 was 93115, checked in by vboxsync, 3 years ago

scm --update-copyright-year

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