Changeset 24651 in vbox for trunk/src/VBox/Additions/x11
- Timestamp:
- Nov 13, 2009 8:18:47 PM (15 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/x11/Installer/x11config-new.pl
r24625 r24651 20 20 # 21 21 22 my $temp="/tmp/xorg.conf"; 23 my $os_type=`uname -s`; 24 my @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"); 29 my $CFG; 30 my $TMP; 22 my $use_hal = 0; 23 my $new_mouse = 0; 24 my $no_bak = 0; 31 25 32 my $config_count = 0; 26 foreach $arg (@ARGV) 27 { 28 if (lc($arg) eq "--usehal") 29 { 30 $use_hal = 1; 31 } 32 elsif (lc($arg) eq "--newmouse") 33 { 34 $new_mouse = 1; 35 } 36 elsif (lc($arg) eq "--nobak") 37 { 38 $no_bak = 1; 39 } 40 else 41 { 42 my $cfg = $arg; 43 my $CFG; 44 my $xkbopts = ""; 45 if (open(CFG, $cfg)) 46 { 47 my $TMP; 48 my $temp = $cfg.".vbox.tmp"; 49 open(TMP, ">$temp") or die "Can't create $TMP: $!\n"; 33 50 34 foreach $cfg (@cfg_files) 35 { 51 my $in_section = 0; 52 print TMP "# VirtualBox generated configuration file\n"; 53 print TMP "# based on $cfg.\n"; 36 54 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) 55 while (defined ($line = <CFG>)) 47 56 { 48 my $section = lc($1); 49 if (($section eq "inputdevice") || ($section eq "device")) 57 if ($line =~ /^\s*Section\s*"([a-zA-Z]+)"/i) 50 58 { 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) 59 my $section = lc($1); 60 if ( ($section eq "inputdevice") 61 || ($section eq "device") 62 || ($section eq "serverlayout") 63 || ($section eq "screen") 64 || ($section eq "monitor") 65 || ($section eq "keyboard") 66 || ($section eq "pointer")) 83 67 { 84 $line = " Option \"Device\" \"\/dev\/kdmouse\"\n" 68 $in_section = 1; 69 } 70 } else { 71 if ($line =~ /^\s*EndSection/i) 72 { 73 $line = "# " . $line unless $in_section eq 0; 74 $in_section = 0; 85 75 } 86 76 } 87 77 88 if ($ line =~ /^\s*driver\s+\"(?:fbdev|vga|vesa|vboxvideo|ChangeMe)\"/i)78 if ($in_section) 89 79 { 90 $line = " Driver \"vboxvideo\"\n"; 80 # Remember XKB options 81 if ($line =~ /^\s*option\s+\"xkb/i) 82 { 83 $xkbopts = $xkbopts . $line; 84 } 85 $line = "# " . $line; 91 86 } 87 print TMP $line; 92 88 } 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 } 89 90 if (!$use_hal && !$new_mouse) { 91 print TMP <<EOF; 92 93 Section "InputDevice" 94 Identifier "mouse" 95 Driver "vboxmouse" 96 Option "Buttons" "9" 97 Option "Device" "/dev/input/mice" 98 Option "Name" "VirtualBox Mouse Buttons" 99 Option "Protocol" "explorerps/2" 100 Option "Vendor" "Sun Microsystems Inc" 101 Option "ZAxisMapping" "4 5" 102 Option "CorePointer" 103 EndSection 104 105 Section "InputDevice" 106 Identifier "keyboard" 107 Driver "keyboard" 108 $xkbopts Option "Protocol" "Standard" 109 Option "CoreKeyboard" 110 EndSection 111 EOF 100 112 } 101 print TMP $line; 113 114 if (!$use_hal && $new_mouse) { 115 print TMP <<EOF; 116 117 Section "InputDevice" 118 Driver "mouse" 119 Identifier "Mouse[1]" 120 Option "Buttons" "9" 121 Option "Device" "/dev/input/mice" 122 Option "Name" "VirtualBox Mouse Buttons" 123 Option "Protocol" "explorerps/2" 124 Option "Vendor" "Sun Microsystems Inc" 125 Option "ZAxisMapping" "4 5" 126 Option "CorePointer" 127 EndSection 128 129 Section "InputDevice" 130 Driver "vboxmouse" 131 Identifier "Mouse[2]" 132 Option "Device" "/dev/vboxguest" 133 Option "Name" "VirtualBox Mouse" 134 Option "Vendor" "Sun Microsystems Inc" 135 Option "SendCoreEvents" 136 EndSection 137 138 Section "InputDevice" 139 Identifier "keyboard[0]" 140 Driver "kbd" 141 $xkbopts Option "Protocol" "Standard" 142 Option "CoreKeyboard" 143 EndSection 144 145 Section "ServerLayout" 146 Identifier "Layout[all]" 147 InputDevice "Keyboard[0]" "CoreKeyboard" 148 InputDevice "Mouse[1]" "CorePointer" 149 InputDevice "Mouse[2]" "SendCoreEvents" 150 Option "Clone" "off" 151 Option "Xinerama" "off" 152 Screen "Screen[0]" 153 EndSection 154 EOF 155 } 156 print TMP <<EOF; 157 158 Section "Monitor" 159 Identifier "Monitor[0]" 160 ModelName "VirtualBox Virtual Output" 161 VendorName "Sun Microsystems Inc" 162 EndSection 163 164 Section "Device" 165 BoardName "VirtualBox Graphics" 166 Driver "vboxvideo" 167 Identifier "Device[0]" 168 VendorName "Sun Microsystems Inc" 169 EndSection 170 171 Section "Screen" 172 SubSection "Display" 173 Depth 24 174 EndSubSection 175 Device "Device[0]" 176 Identifier "Screen[0]" 177 Monitor "Monitor[0]" 178 EndSection 179 EOF 180 close(TMP); 181 182 system("cp", $cfg, $cfg.".vbox") unless 183 ($no_bak eq 1 || -e $cfg.".vbox"); 184 rename $cfg, $cfg.".bak" unless $no_bak eq 1; 185 rename $temp, $cfg; 102 186 } 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 used123 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 187 } 130 188 } 131 132 $config_count != 0 or die "Could not find any X11 configuration files"; 189 exit 0
Note:
See TracChangeset
for help on using the changeset viewer.