VirtualBox

source: vbox/trunk/src/VBox/Additions/x11/Installer/x11config.pl@ 69496

Last change on this file since 69496 was 69496, checked in by vboxsync, 7 years ago

*: scm --update-copyright-year

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 4.3 KB
Line 
1#!/usr/bin/perl -w
2# $Id: x11config.pl 69496 2017-10-28 14:55:58Z vboxsync $
3## @file
4# Guest Additions X11 config update script
5#
6
7#
8# Copyright (C) 2006-2017 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
19my $temp="/tmp/xorg.conf";
20my $os_type=`uname -s`;
21my @cfg_files = ("/etc/X11/xorg.conf-4", "/etc/X11/xorg.conf", "/etc/X11/.xorg.conf", "/etc/xorg.conf",
22 "/usr/etc/X11/xorg.conf-4", "/usr/etc/X11/xorg.conf", "/usr/lib/X11/xorg.conf-4",
23 "/usr/lib/X11/xorg.conf", "/etc/X11/XF86Config-4", "/etc/X11/XF86Config",
24 "/etc/XF86Config", "/usr/X11R6/etc/X11/XF86Config-4", "/usr/X11R6/etc/X11/XF86Config",
25 "/usr/X11R6/lib/X11/XF86Config-4", "/usr/X11R6/lib/X11/XF86Config");
26my $CFG;
27my $TMP;
28
29my $config_count = 0;
30
31foreach $cfg (@cfg_files)
32{
33
34 if (open(CFG, $cfg))
35 {
36 open(TMP, ">$temp") or die "Can't create $TMP: $!\n";
37
38 my $have_mouse = 0;
39 my $in_section = 0;
40
41 while (defined ($line = <CFG>))
42 {
43 if ($line =~ /^\s*Section\s*"([a-zA-Z]+)"/i)
44 {
45 my $section = lc($1);
46 if (($section eq "inputdevice") || ($section eq "device"))
47 {
48 $in_section = 1;
49 }
50 if ($section eq "serverlayout")
51 {
52 $in_layout = 1;
53 }
54 } else {
55 if ($line =~ /^\s*EndSection/i)
56 {
57 $in_section = 0;
58 $in_layout = 0;
59 }
60 }
61
62 if ($in_section)
63 {
64 if ($line =~ /^\s*driver\s+\"(?:mouse|vboxmouse)\"/i)
65 {
66 $line = " Driver \"vboxmouse\"\n Option \"CorePointer\"\n";
67 $have_mouse = 1
68 }
69
70 # Other drivers sending events interfere badly with pointer integration
71 if ($line =~ /^\s*option\s+\"(?:alwayscore|sendcoreevents|corepointer)\"/i)
72 {
73 $line = "";
74 }
75
76 # Solaris specific: /dev/kdmouse for PS/2 and not /dev/mouse
77 if ($os_type =~ 'SunOS')
78 {
79 if ($line =~ /^\s*option\s+\"(?:device)\"\s+\"(?:\/dev\/mouse)\"/i)
80 {
81 $line = " Option \"Device\" \"\/dev\/kdmouse\"\n"
82 }
83 }
84
85 if ($line =~ /^\s*driver\s+\"(?:fbdev|vga|vesa|vboxvideo|ChangeMe)\"/i)
86 {
87 $line = " Driver \"vboxvideo\"\n";
88 }
89 }
90 if ($in_layout)
91 {
92 # Other drivers sending events interfere badly with pointer integration
93 if ( $line =~ /^\s*inputdevice.*\"(?:alwayscore|sendcoreevents)\"/i)
94 {
95 $line = "";
96 }
97 }
98 print TMP $line;
99 }
100
101 if (!$have_mouse) {
102 print TMP "\n";
103 print TMP "Section \"InputDevice\"\n";
104 print TMP " Identifier \"VBoxMouse\"\n";
105 print TMP " Driver \"vboxmouse\"\n";
106 if ($os_type eq 'SunOS')
107 {
108 print TMP " Option \"Device\" \"\/dev\/kdmouse\"\n";
109 }
110 print TMP " Option \"CorePointer\"\n";
111 print TMP "EndSection\n";
112 }
113 close(TMP);
114
115 rename $cfg, $cfg.".bak";
116 system("cp $temp $cfg");
117 unlink $temp;
118
119 # Solaris specific: Rename our modified .xorg.conf to xorg.conf for it to be used
120 if (($os_type =~ 'SunOS') && ($cfg =~ '/etc/X11/.xorg.conf'))
121 {
122 system("mv -f $cfg /etc/X11/xorg.conf");
123 }
124
125 $config_count++;
126 }
127}
128
129$config_count != 0 or die "Could not find any X11 configuration files";
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