summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbin/drak3d16
-rw-r--r--lib/Xconfig/glx.pm8
2 files changed, 15 insertions, 9 deletions
diff --git a/bin/drak3d b/bin/drak3d
index ec10a6e..1cb2f07 100755
--- a/bin/drak3d
+++ b/bin/drak3d
@@ -27,12 +27,18 @@ BEGIN { unshift @::textdomains, 'drak3d' }
use standalone;
use common;
use interactive;
+use do_pkgs;
use Xconfig::glx;
use any;
use Getopt::Long;
-my $in = interactive->vnew('su');
-my $glx = Xconfig::glx::detect_may_install($in) or $in->exit;
+my $in = eval { interactive->vnew('su') };
+$in || $::auto or die $@;
+my $do_pkgs = $in ? $in->do_pkgs : do_pkgs_standalone->new;
+
+sub exit_program { $in ? $in->exit(@_) : exit(@_) }
+
+my $glx = Xconfig::glx::detect_may_install($do_pkgs) or exit_program();
my $running_wm = any::running_window_manager();
GetOptions(
@@ -149,9 +155,9 @@ if ($::auto) {
} else {
$res = Xconfig::glx::choose_interactive($in, $glx);
}
-if ($res && Xconfig::glx::install($in, $glx)) {
+if ($res && Xconfig::glx::install($do_pkgs, $glx)) {
Xconfig::glx::write($glx);
- any::ask_for_X_restart($in);
+ any::ask_for_X_restart($in) if $in;
}
-$in->exit;
+exit_program();
diff --git a/lib/Xconfig/glx.pm b/lib/Xconfig/glx.pm
index 39d2606..f0e65c8 100644
--- a/lib/Xconfig/glx.pm
+++ b/lib/Xconfig/glx.pm
@@ -197,8 +197,8 @@ sub detect() {
}
sub detect_may_install {
- my ($in) = @_;
- $in->do_pkgs->ensure_is_installed('mesa-demos', '/usr/bin/glxinfo') or return;
+ my ($do_pkgs) = @_;
+ $do_pkgs->ensure_is_installed('mesa-demos', '/usr/bin/glxinfo') or return;
Xconfig::glx::detect();
}
@@ -234,7 +234,7 @@ sub choose_interactive {
}
sub install {
- my ($in, $glx) = @_;
+ my ($do_pkgs, $glx) = @_;
my $server = find { $_->{method} eq $glx->{method} } @gl_compositing_servers;
my $wm = find { $_->{wm} eq $glx->{wm} } @gl_compositing_wms;
my @sessions = any::sessions();
@@ -243,7 +243,7 @@ sub install {
@{$entry->{packages}},
map { @{$entry->{desktop_packages}{$_} || []} } @sessions;
} grep { $_ } $server, $wm;
- $in->do_pkgs->ensure_are_installed(\@packages);
+ $do_pkgs->ensure_are_installed(\@packages);
}
#- FIXME: move in common.pm and factorize with network::network::proxy_configure_gnome