diff options
Diffstat (limited to 'perl-install/standalone/drakedm')
| -rwxr-xr-x[-rw-r--r--] | perl-install/standalone/drakedm | 73 |
1 files changed, 51 insertions, 22 deletions
diff --git a/perl-install/standalone/drakedm b/perl-install/standalone/drakedm index 064fffded..6e7d42304 100644..100755 --- a/perl-install/standalone/drakedm +++ b/perl-install/standalone/drakedm @@ -1,6 +1,6 @@ #!/usr/bin/perl # DrakxDM -- Display Manager chooser -# Copyright (C) 2002 MandrakeSoft (tvignaud@mandrakesoft.com) +# Copyright (C) 2003-2008 Mandriva (thierry.vignaud.com) # # 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 @@ -21,40 +21,69 @@ use lib qw(/usr/lib/libDrakX); use standalone; #- warning, standalone must be loaded very first, for 'explanations' use common; +use any; use interactive; +use services; +use run_program; + +$ugtk3::wm_icon = "/usr/share/mcc/themes/default/drakedm-mdk.png"; my $in = 'interactive'->vnew('su'); my $cfg_file = '/etc/sysconfig/desktop'; -my %dm = ('GNOME' => 'GDM (GNOME Display Manager)', - 'KDM' => 'KDM (KDE Display Manager)', - 'KDE' => 'MdkKDM (Mandrake Display Manager)', - 'XDM' => 'XDM (X Display Manager)', - ); +my @list = map { + my %l = map { /(\S+)=(.*)/ } cat_($_); + \%l; +} sort(glob("/usr/share/X11/dm.d/*.conf")); -my $dm = 'KDE'; +my @_DESCRIPTIONS_for_i18n = ( + N("GDM (GNOME Display Manager)"), + N("SDDM (Simple Desktop Display Manager)"), + N("XDM (X Display Manager)"), +); -foreach (cat_($cfg_file)) { - $dm = uc($1) if /^DISPLAYMANAGER=(.*)$/; +if (!$::expert) { + @list = grep { -e $_->{EXEC} } @list; } -if (my $new_dm = $in->ask_from_list_(N("Choosing a display manager"), - formatAlaTeX(N("X11 Display Manager allows you to graphically log +my $dm_name = basename(readlink("/etc/systemd/system/display-manager.service")) =~ s/(.*)\.service/$1/r; +my $dm = (find { basename($_->{EXEC}) eq $dm_name } @list) || $list[0]; + +start: +if ($in->ask_from(N("Choosing a display manager"), + formatAlaTeX(N("X11 Display Manager allows you to graphically log into your system with the X Window System running and supports running several different X sessions on your local machine at the same time.")), - [ sort values %dm ], - $dm{$dm} - ) + [ + { + allow_empty_list => 1, + list => \@list, + val => \$dm, + type => 'list', + format => sub { translate($_[0]{DESCRIPTION}) }, + } + ] + ) + && $dm ) { - $new_dm = { reverse %dm }->{$new_dm}; - log::explanations("modified file $cfg_file"); - substInFile { - s/^(DISPLAYMANAGER)=.*(\n|)//; - s/^\n//g; - $_ .= "\nDISPLAYMANAGER=$new_dm\n" if eof; - } $cfg_file; + $in->do_pkgs->ensure_is_installed($dm->{PACKAGE}, $dm->{EXEC}) or goto start; + $dm_name = basename($dm->{EXEC}); + addVarsInSh($cfg_file, { DISPLAYMANAGER => $dm_name }); + symlinkf("/usr/lib/systemd/system/$dm_name.service", "$::prefix/etc/systemd/system/display-manager.service"); + log::explanations(qq(Switching to "$dm_name" display manager)); + # martinw: I can't find a way to get a clean switch between display managers when one is running. + # But keep the old code (to preserve the translations) in case someone else can. + my $can_switch_cleanly = 0; + if ($can_switch_cleanly && any::running_window_manager()) { + $in->ask_yesorno('', N("The change is done, do you want to restart the dm service?"), 1) and + $in->ask_yesorno('', N("You are going to close all running programs and lose your current session. Are you really sure that you want to restart the dm service?"), 1) and + run_program::raw({ detach => 1 }, 'systemctl', 'restart', 'display-manager.service', '>', '/dev/null', '2>', '/dev/null'); + } elsif (any::running_window_manager()) { + $in->ask_warn('', N("The change is done and will take effect when you next boot the system")); + } else { + run_program::run('systemctl', 'daemon-reload'); + } } - $in->exit(0); |
