File 0001-Read-the-DISPLAYMANAGER_AUTOLOGIN-value-from-sysconf.patch of Package sddm
From 5cc1a99fadce25298124cde0be8be9bab25c87cc 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 | 6 ++++++
4 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3107c7a..10839b1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -183,6 +183,7 @@ set(CONFIG_FILE "${CMAKE_INSTALL_FULL_SYSCONFDIR}/sddm.conf"
set(CONFIG_DIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}/sddm.conf.d" CACHE PATH "Path of the sddm config directory")
set(ACCOUNTSSERVICE_DATA_DIR "/var/lib/AccountsService" CACHE PATH "Path of the accountsservice data 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-qt${QT_MAJOR_VERSION}" CACHE PATH "Components translations directory")
diff --git a/src/common/Configuration.h b/src/common/Configuration.h
index 54bcace..484fae1 100644
--- a/src/common/Configuration.h
+++ b/src/common/Configuration.h
@@ -101,14 +101,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"));
diff --git a/src/common/Constants.h.in b/src/common/Constants.h.in
index 7b2669e..9968d44 100644
--- a/src/common/Constants.h.in
+++ b/src/common/Constants.h.in
@@ -36,6 +36,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@"
diff --git a/src/daemon/Display.cpp b/src/daemon/Display.cpp
index a9c80dc..6c5a968 100644
--- a/src/daemon/Display.cpp
+++ b/src/daemon/Display.cpp
@@ -35,6 +35,7 @@
#include <QFile>
#include <QTimer>
#include <QLocalSocket>
+#include <QSettings>
#include <pwd.h>
#include <unistd.h>
@@ -272,6 +273,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
--
2.42.0