VirtualBox

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

Last change on this file since 35273 was 32388, checked in by vboxsync, 14 years ago

more branding fixes

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