1 |
#!/usr/bin/perl |
2 |
|
3 |
# XFdrake |
4 |
# Copyright (C) 1999-2006 Mandriva (pixel@mandrakesoft.com) |
5 |
# |
6 |
# This program is free software; you can redistribute it and/or modify |
7 |
# it under the terms of the GNU General Public License as published by |
8 |
# the Free Software Foundation; either version 2, or (at your option) |
9 |
# any later version. |
10 |
# |
11 |
# This program is distributed in the hope that it will be useful, |
12 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
# GNU General Public License for more details. |
15 |
# |
16 |
# You should have received a copy of the GNU General Public License |
17 |
# along with this program; if not, write to the Free Software |
18 |
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 |
|
20 |
use lib qw(/usr/lib/libDrakX); |
21 |
|
22 |
# i18n: IMPORTANT: to get correct namespace (drakx-kbd-mouse-x11 instead of libDrakX) |
23 |
BEGIN { unshift @::textdomains, 'drakx-kbd-mouse-x11' } |
24 |
|
25 |
use standalone; #- warning, standalone must be loaded very first, for 'explanations' |
26 |
|
27 |
use Xconfig::main; |
28 |
use Xconfig::xfree; |
29 |
use Xconfig::default; |
30 |
use interactive; |
31 |
use modules; |
32 |
use common; |
33 |
use any; |
34 |
use c; |
35 |
|
36 |
my ($configure_this) = grep { !/^-/ } @ARGV; |
37 |
$configure_this = 'resolution' if $0 =~ /Xdrakres/; |
38 |
$configure_this ||= $::auto ? 'auto_install' : 'everything'; |
39 |
|
40 |
{ |
41 |
my $in = 'interactive'->vnew('su'); |
42 |
|
43 |
my $rc = do { |
44 |
my $options = { allowFB => listlength(cat_("/proc/fb")) }; |
45 |
|
46 |
if ($configure_this eq 'everything') { |
47 |
check_XFree($in); |
48 |
my ($_raw_X, $rc) = Xconfig::main::configure_everything_or_configure_chooser($in, $options, $::auto); |
49 |
$rc; |
50 |
} elsif ($configure_this eq 'auto_install') { |
51 |
Xconfig::main::configure_everything_auto_install(Xconfig::default::configure($in->do_pkgs), $in->do_pkgs, {}, $options); |
52 |
} elsif ($configure_this eq 'monitor') { |
53 |
Xconfig::main::configure_monitor($in); |
54 |
} elsif ($configure_this eq 'resolution') { |
55 |
Xconfig::main::configure_resolution($in); |
56 |
} |
57 |
}; |
58 |
if (!$::auto) { |
59 |
if ($rc =~ /need_xrandr(.*)/) { |
60 |
my $opts = $1; |
61 |
my $before = `xrandr`; |
62 |
run_program::run('xrandr', split(' ', $opts)); |
63 |
my $after = `xrandr`; |
64 |
if ($before eq $after) { |
65 |
log::l("xrandr $opts failed, defaulting to ask_for_X_restart"); |
66 |
any::ask_for_X_restart($in); |
67 |
} |
68 |
} elsif ($rc eq 'need_restart') { |
69 |
any::ask_for_X_restart($in); |
70 |
} elsif ($rc eq 'need_reboot') { |
71 |
$in->ask_warn('', N("You need to reboot for changes to take effect")); |
72 |
} |
73 |
} |
74 |
|
75 |
$in->exit($rc ? 0 : 1); |
76 |
} |
77 |
|
78 |
sub check_XFree { |
79 |
my ($in) = @_; |
80 |
|
81 |
#- set the standard configuration |
82 |
{ |
83 |
my $f = "/etc/X11/xorg.conf"; |
84 |
symlinkf("$_.standard", $f) if -l $f && -e "$f.standard"; |
85 |
} |
86 |
|
87 |
$in->do_pkgs->ensure_are_installed(['task-x11']) or $in->exit; |
88 |
|
89 |
system("mount /proc 2>/dev/null"); # ensure /proc is mounted for pci probing |
90 |
} |