File 0001-Read-the-DISPLAYMANAGER_AUTOLOGIN-value-from-sysconf.patch of Package sddm

From 25cc8be1ccb41de8f789ac4ea55437a3159e5d4e Mon Sep 17 00:00:00 2001
From: Hrvoje Senjan <hrvoje.senjan@gmail.com>
Date: Sat, 2 Sep 2017 11:27:01 +0200
Subject: [PATCH] Read the DISPLAYMANAGER_AUTOLOGIN value from
 sysconfig/displaymanager

Support DISPLAYMANAGER_AUTOLOGIN entry from /etc/sysconfig/displaymanager,
the value overwrites any entry in sddm.conf/[Autologin]/User.
Patch also defaults to default.desktop as default autologin session.
This is controlled only by sddm.conf file.
---
 CMakeLists.txt             |  1 +
 src/common/Configuration.h |  5 +++--
 src/common/Constants.h.in  |  1 +
 src/daemon/Display.cpp     | 12 ++++++++++++
 4 files changed, 17 insertions(+), 2 deletions(-)

Index: sddm-0.17.0/CMakeLists.txt
===================================================================
--- sddm-0.17.0.orig/CMakeLists.txt
+++ sddm-0.17.0/CMakeLists.txt
@@ -186,6 +186,7 @@ set(WAYLAND_SESSION_COMMAND     "${DATA_
 set(CONFIG_FILE                 "${CMAKE_INSTALL_FULL_SYSCONFDIR}/sddm.conf"        CACHE PATH      "Path of the sddm config file")
 set(CONFIG_DIR                  "${CMAKE_INSTALL_FULL_SYSCONFDIR}/sddm.conf.d"      CACHE PATH      "Path of the sddm config directory")
 set(SYSTEM_CONFIG_DIR           "${CMAKE_INSTALL_PREFIX}/lib/sddm/sddm.conf.d"      CACHE PATH      "Path of the system sddm config directory")
+set(DISPLAY_MANAGER_CONFIG_FILE "${CMAKE_INSTALL_FULL_SYSCONFDIR}/sysconfig/displaymanager"        CACHE PATH      "Path of the sysconfig/displaymanager config file")
 set(LOG_FILE                    "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/log/sddm.log"  CACHE PATH      "Path of the sddm log file")
 set(DBUS_CONFIG_FILENAME        "org.freedesktop.DisplayManager.conf"               CACHE STRING    "Name of the sddm config file")
 set(COMPONENTS_TRANSLATION_DIR  "${DATA_INSTALL_DIR}/translations"                  CACHE PATH      "Components translations directory")
Index: sddm-0.17.0/src/common/Configuration.h
===================================================================
--- sddm-0.17.0.orig/src/common/Configuration.h
+++ sddm-0.17.0/src/common/Configuration.h
@@ -94,14 +94,15 @@ namespace SDDM {
 
         Section(Autologin,
             Entry(User,                QString,     QString(),                                  _S("Username for autologin session"));
-            Entry(Session,             QString,     QString(),                                  _S("Name of session file for autologin session (if empty try last logged in)"));
+            Entry(Session,             QString,     _S("default.desktop"),                      _S("Name of session file for autologin session (if empty try last logged in)"));
+
             Entry(Relogin,             bool,        false,                                      _S("Whether sddm should automatically log back into sessions when they exit"));
         );
     );
 
     Config(StateConfig, []()->QString{auto tmp = getpwnam("sddm"); return tmp ? QString::fromLocal8Bit(tmp->pw_dir) : QStringLiteral(STATE_DIR);}().append(QStringLiteral("/state.conf")), QString(), QString(),
         Section(Last,
-            Entry(Session,         QString,     QString(),                                      _S("Name of the session for the last logged-in user.\n"
+            Entry(Session,         QString,     _S("/usr/share/xsessions/default.desktop"),     _S("Name of the session for the last logged-in user.\n"
                                                                                                    "This session will be preselected when the login screen appears."));
             Entry(User,            QString,     QString(),                                      _S("Name of the last logged-in user.\n"
                                                                                                    "This user will be preselected when the login screen appears"));
Index: sddm-0.17.0/src/common/Constants.h.in
===================================================================
--- sddm-0.17.0.orig/src/common/Constants.h.in
+++ sddm-0.17.0/src/common/Constants.h.in
@@ -35,6 +35,7 @@
 #define CONFIG_FILE                 "@CONFIG_FILE@"
 #define CONFIG_DIR                  "@CONFIG_DIR@"
 #define SYSTEM_CONFIG_DIR           "@SYSTEM_CONFIG_DIR@"
+#define DISPLAY_MANAGER_CONFIG_FILE "@DISPLAY_MANAGER_CONFIG_FILE@"
 
 #define LOG_FILE                    "@LOG_FILE@"
 #define PID_FILE                    "@PID_FILE@"
Index: sddm-0.17.0/src/daemon/Display.cpp
===================================================================
--- sddm-0.17.0.orig/src/daemon/Display.cpp
+++ sddm-0.17.0/src/daemon/Display.cpp
@@ -35,6 +35,7 @@
 #include <QDebug>
 #include <QFile>
 #include <QTimer>
+#include <QSettings>
 
 #include <pwd.h>
 #include <unistd.h>
@@ -151,6 +152,11 @@ namespace SDDM {
         // log message
         qDebug() << "Display server started.";
 
+        QSettings sysconfSettings(QStringLiteral(DISPLAY_MANAGER_CONFIG_FILE), QSettings::NativeFormat);
+        QString sysconfigUser = sysconfSettings.value(QStringLiteral("DISPLAYMANAGER_AUTOLOGIN"), QStringLiteral("")).toString();
+
+        mainConfig.Autologin.User.set(sysconfigUser);
+
         if ((daemonApp->first || mainConfig.Autologin.Relogin.get()) &&
             !mainConfig.Autologin.User.get().isEmpty()) {
             // reset first flag
openSUSE Build Service is sponsored by