From d592a5bb947ee50b74a39c2d9d979c9653d2d1c8 Mon Sep 17 00:00:00 2001
From: Adriaan de Groot <groot@kde.org>
Date: Mon, 7 Oct 2019 15:54:55 +0200
Subject: [PATCH] [displaymanager] Fix sysconfig-only

 - Improve documentation of the settings
 - If sysconfigSetup is true, **only** setup sysconfig and ignore
   the rest. This seems to be consistent with existing openSUSE-
   derivative distro's, which set displaymanagers to something
   nonsensical.
---
 .../displaymanager/displaymanager.conf        | 22 ++++++++++++++-----
 src/modules/displaymanager/main.py            |  7 +++---
 2 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/src/modules/displaymanager/displaymanager.conf b/src/modules/displaymanager/displaymanager.conf
index c3e0e1160..f6b5a397f 100644
--- a/src/modules/displaymanager/displaymanager.conf
+++ b/src/modules/displaymanager/displaymanager.conf
@@ -1,9 +1,17 @@
 # Configure one or more display managers (e.g. SDDM)
 # with a "best effort" approach.
+#
+# This module also sets up autologin, if the feature is enabled in
+# globalstorage (where it would come from the users page).
 ---
-#The DM module attempts to set up all the DMs found in this list, in that precise order.
-#It also sets up autologin, if the feature is enabled in globalstorage.
-#The displaymanagers list can also be set in globalstorage, and in that case it overrides anything set up here.
+# The DM module attempts to set up all the DMs found in this list, in the
+# precise order listed. The displaymanagers list can also be set in
+# globalstorage, and in that case it overrides the setting here.
+#
+# If *sysconfigSetup* is set to *true* (see below, only relevant for
+# openSUSE derivatives) then this list is ignored and only sysconfig
+# is attempted. You can also list "sysconfig" in this list instead.
+#
 displaymanagers:
   - slim
   - sddm
@@ -41,6 +49,10 @@ displaymanagers:
 #packages, and best left to them. Therefore, it is disabled by default.
 basicSetup: false
 
-#If true, setup autologin for openSUSE. This only makes sense on openSUSE
-#derivatives or other systems where /etc/sysconfig/displaymanager exists.
+# If true, setup autologin for openSUSE. This only makes sense on openSUSE
+# derivatives or other systems where /etc/sysconfig/displaymanager exists.
+#
+# The preferred way to pick sysconfig is to just list it in the
+# *displaymanagers* list (as the only one).
+#
 sysconfigSetup: false
diff --git a/src/modules/displaymanager/main.py b/src/modules/displaymanager/main.py
index ca42e6204..9e4d61d4c 100644
--- a/src/modules/displaymanager/main.py
+++ b/src/modules/displaymanager/main.py
@@ -879,6 +879,10 @@ def run():
     if libcalamares.globalstorage.contains("displayManagers"):
         displaymanagers = libcalamares.globalstorage.value("displayManagers")
 
+    if ("sysconfigSetup" in libcalamares.job.configuration
+            and libcalamares.job.configuration["sysconfigSetup"]):
+        displaymanagers = ["sysconfig"]
+
     if not displaymanagers:
         return (
             _("No display managers selected for the displaymanager module."),
@@ -890,9 +894,6 @@ def run():
     root_mount_point = libcalamares.globalstorage.value("rootMountPoint")
     dm_impl = []
     dm_names = displaymanagers[:]
-    if ("sysconfigSetup" in libcalamares.job.configuration
-            and libcalamares.job.configuration["sysconfigSetup"]):
-        dm_names.append("sysconfig")
     for dm in dm_names:
         # Find the implementation class
         dm_instance = None