#!/usr/bin/perl

use lib qw(/usr/lib/libDrakX);

# i18n: IMPORTANT: to get correct namespace (drakx-kbd-mouse-x11 instead of libDrakX)
BEGIN { unshift @::textdomains, 'drakx-kbd-mouse-x11' }

use standalone;     #- warning, standalone must be loaded very first, for 'explanations'

use common;
use interactive;
use modules;
use mouse;
use c;


$ugtk3::wm_icon = "/usr/share/mcc/themes/default/mousedrake-mdk.png";
my $in = 'interactive'->vnew('su');

my $modules_conf = modules::any_conf->read;

my $mouse = mouse::read();

if (!$::noauto) {
    my $probed_mouse = mouse::detect($modules_conf);
    $mouse = $probed_mouse if !$mouse->{Protocol} || !$probed_mouse->{unsafe};
}

if (!$mouse || !$::auto) {
    $mouse ||= mouse::fullname2mouse('Universal|Any PS/2 & USB mice');
    mouse::select($in, $mouse) or $in->exit(0);
}

mouse::write_conf($in->do_pkgs, $modules_conf, $mouse, 1);

system('systemctl', 'try-restart', 'gpm.service') if -e '/usr/lib/systemd/system/gpm.service';

$in->exit(0);