Blob Blame Raw
From 7f7627bc21ac8693e19c65c8dc3f31c10a786d57 Mon Sep 17 00:00:00 2001
Message-Id: <7f7627bc21ac8693e19c65c8dc3f31c10a786d57.1492299277.git.kevin.kofler@chello.at>
From: Teo Mrnjavac <teo@kde.org>
Date: Tue, 17 Jan 2017 17:02:53 +0100
Subject: [PATCH] Unbreak autologin setting.

Don't assume 'User' exists in autologin section.
https://github.com/calamares/calamares/commit/8d5e4cdb1629fb7e16336ccdfe7950bd6767cde9

Unbreak autologin setting.
https://github.com/calamares/calamares/commit/68e2c4f9013d8a555021b0fed46a0892663ee2af
---
 src/modules/displaymanager/main.py | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/src/modules/displaymanager/main.py b/src/modules/displaymanager/main.py
index 57945fa..0418f4a 100644
--- a/src/modules/displaymanager/main.py
+++ b/src/modules/displaymanager/main.py
@@ -261,19 +261,16 @@ def set_autologin(username, displaymanagers, default_desktop_environment, root_m
         if os.path.isfile(sddm_conf_path):
             sddm_config.read(sddm_conf_path)
 
-        autologin_section = {}
-        if 'Autologin' in sddm_config:
-            autologin_section = sddm_config['Autologin']
+        if 'Autologin' not in sddm_config:
+            sddm_config.add_section('Autologin')
 
         if do_autologin:
-            autologin_section['User'] = username
-        else:
-            del autologin_section['User']
+            sddm_config.set('Autologin', 'User', username)
+        elif sddm_config.has_option('Autologin', 'User'):
+            sddm_config.remove_option('Autologin', 'User')
 
         if default_desktop_environment is not None:
-            autologin_section['Session'] = default_desktop_environment.desktop_file
-
-        sddm_config['Autologin'] = autologin_section
+            sddm_config.set('Autologin', 'Session', default_desktop_environment.desktop_file)
 
         with open(sddm_conf_path, 'w') as sddm_config_file:
             sddm_config.write(sddm_config_file, space_around_delimiters=False)
@@ -351,7 +348,7 @@ def run():
             if default_desktop_environment.desktop_file == "deepin":
                 os.system("sed -i -e \"s/^.greeter-session=.*/greeter-session=lightdm-deepin-greeter/\" {!s}/etc/lightdm/lightdm.conf".format(
                           root_mount_point))
-                          
+
         else:
             libcalamares.utils.debug("lightdm selected but not installed")
             displaymanagers.remove("lightdm")
@@ -437,5 +434,5 @@ def run():
         libcalamares.utils.debug("Unsetting autologin.")
 
     libcalamares.globalstorage.insert("displayManagers", displaymanagers)
-    
+
     return set_autologin(username, displaymanagers, default_desktop_environment, root_mount_point)
-- 
2.9.3