summaryrefslogtreecommitdiffstats
path: root/perl-install/standalone/drakautologin
diff options
context:
space:
mode:
authorThierry Vignaud <thierry.vignaud@gmail.com>2015-05-22 03:09:37 -0400
committerThierry Vignaud <thierry.vignaud@gmail.com>2016-01-02 14:58:10 +0100
commit41fc00cea5d49e46870db72a5612cbe9f67f8e26 (patch)
tree92de7d9d752d764e8a41f4536933cf7d168f84fe /perl-install/standalone/drakautologin
parente1a1d3d2e14a141ff17ab5c550eb966092a19aa9 (diff)
downloaddrakx-41fc00cea5d49e46870db72a5612cbe9f67f8e26.tar
drakx-41fc00cea5d49e46870db72a5612cbe9f67f8e26.tar.gz
drakx-41fc00cea5d49e46870db72a5612cbe9f67f8e26.tar.bz2
drakx-41fc00cea5d49e46870db72a5612cbe9f67f8e26.tar.xz
drakx-41fc00cea5d49e46870db72a5612cbe9f67f8e26.zip
split drakautologin from drakboot (mga#7160)
Diffstat (limited to 'perl-install/standalone/drakautologin')
-rwxr-xr-xperl-install/standalone/drakautologin138
1 files changed, 138 insertions, 0 deletions
diff --git a/perl-install/standalone/drakautologin b/perl-install/standalone/drakautologin
new file mode 100755
index 000000000..109f44a04
--- /dev/null
+++ b/perl-install/standalone/drakautologin
@@ -0,0 +1,138 @@
+#!/usr/bin/perl
+
+# DrakAutoLogin
+# Copyright (C) 2001-2008 Mandriva
+# Yves Duret, Thierry Vignaud
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+use strict;
+use diagnostics;
+use lib qw(/usr/lib/libDrakX);
+
+use standalone; #- warning, standalone must be loaded very first, for 'explanations'
+use common;
+use interactive;
+use any;
+use Xconfig::various;
+
+my $in = 'interactive'->vnew('su');
+
+require ugtk3;
+ugtk3->import(qw(:helpers :wrappers :create));
+require mygtk3;
+mygtk3->import(qw(gtknew));
+
+autologin_choice();
+
+sub run_boot_window {
+ my ($title, $pack_list, $apply_sub) = @_;
+
+ my $w = ugtk3->new($title);
+ my $window = $w->{window};
+ mygtk3::register_main_window($w->{real_window});
+
+ $window->signal_connect(delete_event => sub { ugtk3->exit(0) });
+ unless ($::isEmbedded) {
+ $window->set_border_width(2);
+ ### menus definition
+ # the menus are not shown but they provides shiny shortcut like C-q
+ my $ui = gtknew('UIManager', actions => [
+ # [name, stock_id, value, label, accelerator, tooltip, callback]
+ [ 'FileMenu', undef, N("_File") ],
+ [ 'Quit', undef, N("_Quit"), N("<control>Q"), undef, sub { ugtk3->exit(0) } ],
+ ],
+ string => qq(<ui>
+ <menubar name='MenuBar'>
+ <menu action='FileMenu'>
+ <menuitem action='Quit'/>
+ </menu>
+ </menubar>
+</ui>));
+ $w->{rwindow}->add_accel_group($ui->get_accel_group);
+
+ ######### menus end
+ }
+ gtkadd($window, gtknew('VBox', children => [
+ @$pack_list,
+ 0, create_okcancel({
+ cancel_clicked => sub { ugtk3->exit(0) },
+ ok_clicked => sub {
+ $apply_sub->();
+ ugtk3->exit(0);
+ }
+ }) ]));
+ $window->show_all;
+ gtkflush();
+ $w->main;
+ $in->exit(0);
+}
+
+sub autologin_choice() {
+ my @users = sort(list_users());
+ my @sessions = sort(split(' ', `/usr/sbin/chksession -l`));
+
+ my $x_mode = Xconfig::various::runlevel() == 5;
+ my $auto_mode = any::get_autologin();
+
+ my $user = member($auto_mode->{user}, @users) ? $auto_mode->{user} : $users[0];
+ if (!$user) {
+ # no user, bad but add root anyway:
+ $user = "root";
+ push @users, $user;
+ }
+ my $user_combo = gtknew('ComboBox', text => $user, list => \@users);
+ my $desktop_combo = Gtk3::ComboBoxText->new_with_strings(\@sessions, if_(member($auto_mode->{desktop}, @sessions), $auto_mode->{desktop}));
+
+ my $auto_box = gtknew('Table', col_spacings => 5, row_spacings => 5, homogeneous => 1, children => [
+ [ gtknew('Label_Left', text => N("Default user")), $user_combo ],
+ [ gtknew('Label_Left', text => N("Default desktop")), $desktop_combo ] ]);
+ $auto_box->set_sensitive($auto_mode->{user} ? 1 : 0);
+
+ my @auto_buttons = gtkradio((N("No, I do not want autologin")) x 2,
+ N("Yes, I want autologin with this (user, desktop)"));
+ $auto_buttons[1]->signal_connect('toggled' => sub { $auto_box->set_sensitive($auto_buttons[1]->get_active) });
+ $auto_buttons[0]->signal_connect('toggled' => sub { $auto_box->set_sensitive(!$auto_buttons[0]->get_active) });
+ $auto_buttons[1]->set_active(1) if $auto_mode->{user};
+ $auto_buttons[0]->set_active(1) if !$auto_mode->{user};
+
+ my $x_box;
+ run_boot_window(N("System mode"),
+ [
+ 1, gtknew('VBox', spacing => 5, children_tight => [
+ gtksignal_connect(gtkset_active(gtknew('CheckButton', text => N("Launch the graphical environment when your system starts")),
+ $x_mode),
+ clicked => sub {
+ $x_box->set_sensitive(!$x_mode);
+ $x_mode = !$x_mode;
+ }),
+ $x_box = gtknew('VBox', sensitive => $x_mode, children_tight => [
+ gtknew('VBox', children_tight => [ @auto_buttons ]),
+ $auto_box
+ ]) ])
+ ],
+ sub {
+ Xconfig::various::runlevel($x_mode ? 5 : 3);
+ $::testing and return;
+ if ($auto_buttons[1]->get_active) {
+ $auto_mode->{user} = $user_combo->entry->get_text;
+ $auto_mode->{desktop} = $desktop_combo->entry->get_text;
+ } else {
+ $auto_mode->{user} = undef;
+ $auto_mode->{desktop} = undef;
+ }
+ any::set_autologin($in->do_pkgs, $auto_mode);
+ });
+}