1 | #!/usr/bin/perl -w
|
---|
2 | #
|
---|
3 | # innotek VirtualBox
|
---|
4 | #
|
---|
5 | # Linux Additions X11 config update script
|
---|
6 | #
|
---|
7 | # Copyright (C) 2006-2007 innotek GmbH
|
---|
8 | #
|
---|
9 | # Use only with permission.
|
---|
10 | #
|
---|
11 |
|
---|
12 |
|
---|
13 | my $temp="/tmp/xorg.conf";
|
---|
14 | my @cfg_files = ("/etc/X11/xorg.conf-4", "/etc/X11/xorg.conf", "/etc/xorg.conf",
|
---|
15 | "/usr/etc/X11/xorg.conf-4", "/usr/etc/X11/xorg.conf", "/usr/lib/X11/xorg.conf-4",
|
---|
16 | "/usr/lib/X11/xorg.conf", "/etc/X11/XF86Config-4", "/etc/X11/XF86Config",
|
---|
17 | "/etc/XF86Config", "/usr/X11R6/etc/X11/XF86Config-4", "/usr/X11R6/etc/X11/XF86Config",
|
---|
18 | "/usr/X11R6/lib/X11/XF86Config-4", "/usr/X11R6/lib/X11/XF86Config");
|
---|
19 | my $CFG;
|
---|
20 | my $TMP;
|
---|
21 |
|
---|
22 | my $count_config = 0;
|
---|
23 |
|
---|
24 | foreach $cfg (@cfg_files)
|
---|
25 | {
|
---|
26 |
|
---|
27 | if (open(CFG, $cfg))
|
---|
28 | {
|
---|
29 | open(TMP, ">$temp") or die "Can't create $TMP: $!\n";
|
---|
30 |
|
---|
31 | my $have_mouse = 0;
|
---|
32 | my $in_section = 0;
|
---|
33 |
|
---|
34 | while (defined ($line = <CFG>))
|
---|
35 | {
|
---|
36 | if ($line =~ /^\s*Section\s*"([a-zA-Z]+)"/i)
|
---|
37 | {
|
---|
38 | my $section = lc($1);
|
---|
39 | if (($section eq "inputdevice") || ($section eq "device"))
|
---|
40 | {
|
---|
41 | $in_section = 1;
|
---|
42 | }
|
---|
43 | } else {
|
---|
44 | if ($line =~ /^\s*EndSection/i)
|
---|
45 | {
|
---|
46 | $in_section = 0;
|
---|
47 | }
|
---|
48 | }
|
---|
49 |
|
---|
50 | if ($in_section)
|
---|
51 | {
|
---|
52 | if ($line =~ /^\s*driver\s+\"(?:mouse|vboxmouse)\"/i)
|
---|
53 | {
|
---|
54 | $line = " Driver \"vboxmouse\"\n";
|
---|
55 | $have_mouse = 1
|
---|
56 | }
|
---|
57 |
|
---|
58 | # Other drivers sending events interfere badly with pointer integration
|
---|
59 | if ($line =~ /^\s*driver\s+\"(?:alwayscore|sendcoreevents)\"/i)
|
---|
60 | {
|
---|
61 | $line = "\n";
|
---|
62 | }
|
---|
63 |
|
---|
64 | if ($line =~ /^\s*driver\s+\"(?:fbdev|vga|vesa|vboxvideo|ChangeMe)\"/i)
|
---|
65 | {
|
---|
66 | $line = " Driver \"vboxvideo\"\n";
|
---|
67 | }
|
---|
68 | }
|
---|
69 | print TMP $line;
|
---|
70 | }
|
---|
71 |
|
---|
72 | rename $cfg, $cfg.".bak";
|
---|
73 | system("cp $temp $cfg");
|
---|
74 | unlink $temp;
|
---|
75 |
|
---|
76 | if ($have_mouse == 0) {
|
---|
77 | system("echo >> $cfg");
|
---|
78 | system("echo 'Section \"InputDevice\"' >> $cfg");
|
---|
79 | system("echo ' Identifier \"VBoxMouse\"' >> $cfg");
|
---|
80 | system("echo ' Driver \"vboxmouse\"' >> $cfg");
|
---|
81 | system("echo ' Option \"CorePointer\"' >> $cfg");
|
---|
82 | system("echo 'EndSection' >> $cfg");
|
---|
83 | }
|
---|
84 | $config_count++;
|
---|
85 | }
|
---|
86 | }
|
---|
87 |
|
---|
88 | $config_count != 0 or die "Could not find any X11 configuration files";
|
---|