VirtualBox

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

Last change on this file since 99743 was 98103, checked in by vboxsync, 2 years ago

Copyright year updates by scm.

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