VirtualBox

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

Last change on this file since 28105 was 18265, checked in by vboxsync, 16 years ago

config file cleanup + small copyright year update

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 4.4 KB
Line 
1#!/usr/bin/perl -w
2#
3# Sun VirtualBox
4#
5# Guest Additions X11 config update script
6#
7# Copyright (C) 2006-2009 Sun Microsystems, Inc.
8#
9# This file is part of VirtualBox Open Source Edition (OSE), as
10# available from http://www.virtualbox.org. This file is free software;
11# you can redistribute it and/or modify it under the terms of the GNU
12# General Public License (GPL) as published by the Free Software
13# Foundation, in version 2 as it comes in the "COPYING" file of the
14# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16#
17# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18# Clara, CA 95054 USA or visit http://www.sun.com if you need
19# additional information or have any questions.
20#
21
22my $temp="/tmp/xorg.conf";
23my $os_type=`uname -s`;
24my @cfg_files = ("/etc/X11/xorg.conf-4", "/etc/X11/xorg.conf", "/etc/X11/.xorg.conf", "/etc/xorg.conf",
25 "/usr/etc/X11/xorg.conf-4", "/usr/etc/X11/xorg.conf", "/usr/lib/X11/xorg.conf-4",
26 "/usr/lib/X11/xorg.conf", "/etc/X11/XF86Config-4", "/etc/X11/XF86Config",
27 "/etc/XF86Config", "/usr/X11R6/etc/X11/XF86Config-4", "/usr/X11R6/etc/X11/XF86Config",
28 "/usr/X11R6/lib/X11/XF86Config-4", "/usr/X11R6/lib/X11/XF86Config");
29my $CFG;
30my $TMP;
31
32my $config_count = 0;
33
34foreach $cfg (@cfg_files)
35{
36
37 if (open(CFG, $cfg))
38 {
39 open(TMP, ">$temp") or die "Can't create $TMP: $!\n";
40
41 my $have_mouse = 0;
42 my $in_section = 0;
43
44 while (defined ($line = <CFG>))
45 {
46 if ($line =~ /^\s*Section\s*"([a-zA-Z]+)"/i)
47 {
48 my $section = lc($1);
49 if (($section eq "inputdevice") || ($section eq "device"))
50 {
51 $in_section = 1;
52 }
53 if ($section eq "serverlayout")
54 {
55 $in_layout = 1;
56 }
57 } else {
58 if ($line =~ /^\s*EndSection/i)
59 {
60 $in_section = 0;
61 $in_layout = 0;
62 }
63 }
64
65 if ($in_section)
66 {
67 if ($line =~ /^\s*driver\s+\"(?:mouse|vboxmouse)\"/i)
68 {
69 $line = " Driver \"vboxmouse\"\n Option \"CorePointer\"\n";
70 $have_mouse = 1
71 }
72
73 # Other drivers sending events interfere badly with pointer integration
74 if ($line =~ /^\s*option\s+\"(?:alwayscore|sendcoreevents|corepointer)\"/i)
75 {
76 $line = "";
77 }
78
79 # Solaris specific: /dev/kdmouse for PS/2 and not /dev/mouse
80 if ($os_type =~ 'SunOS')
81 {
82 if ($line =~ /^\s*option\s+\"(?:device)\"\s+\"(?:\/dev\/mouse)\"/i)
83 {
84 $line = " Option \"Device\" \"\/dev\/kdmouse\"\n"
85 }
86 }
87
88 if ($line =~ /^\s*driver\s+\"(?:fbdev|vga|vesa|vboxvideo|ChangeMe)\"/i)
89 {
90 $line = " Driver \"vboxvideo\"\n";
91 }
92 }
93 if ($in_layout)
94 {
95 # Other drivers sending events interfere badly with pointer integration
96 if ( $line =~ /^\s*inputdevice.*\"(?:alwayscore|sendcoreevents)\"/i)
97 {
98 $line = "";
99 }
100 }
101 print TMP $line;
102 }
103
104 if (!$have_mouse) {
105 print TMP "\n";
106 print TMP "Section \"InputDevice\"\n";
107 print TMP " Identifier \"VBoxMouse\"\n";
108 print TMP " Driver \"vboxmouse\"\n";
109 if ($os_type eq 'SunOS')
110 {
111 print TMP " Option \"Device\" \"\/dev\/kdmouse\"\n";
112 }
113 print TMP " Option \"CorePointer\"\n";
114 print TMP "EndSection\n";
115 }
116 close(TMP);
117
118 rename $cfg, $cfg.".bak";
119 system("cp $temp $cfg");
120 unlink $temp;
121
122 # Solaris specific: Rename our modified .xorg.conf to xorg.conf for it to be used
123 if (($os_type =~ 'SunOS') && ($cfg =~ '/etc/X11/.xorg.conf'))
124 {
125 system("mv -f $cfg /etc/X11/xorg.conf");
126 }
127
128 $config_count++;
129 }
130}
131
132$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