File 0004-Write-new-themes-in-usr-local.patch of Package sddm-kcm6

Index: sddm-kcm-6.4.4/sddmauthhelper.cpp
===================================================================
--- sddm-kcm-6.4.4.orig/sddmauthhelper.cpp
+++ sddm-kcm-6.4.4/sddmauthhelper.cpp
@@ -293,6 +293,13 @@ ActionReply SddmAuthHelper::save(const Q
     QString themeConfigFile = args[QStringLiteral("theme.conf.user")].toString();
 
     if (!themeConfigFile.isEmpty()) {
+        QFileInfo themeConfigFileInfo(themeConfigFile);
+
+        // If the original theme directory is not writable, update the path
+        if (!QFileInfo(themeConfigFileInfo.absoluteDir().path()).isWritable()) {
+            themeConfigFile = QStringLiteral("/usr/local/share/sddm/themes/") + themeConfigFileInfo.absoluteDir().dirName() + QStringLiteral("/theme.conf.user");
+        }
+
         themeConfig = openConfig(themeConfigFile);
     }
 
@@ -403,10 +410,21 @@ ActionReply SddmAuthHelper::installtheme
         return ActionReply::HelperErrorReply();
     }
 
-    const QString themesBaseDir = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("sddm/themes"), QStandardPaths::LocateDirectory);
+    QString themesBaseDir = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("sddm/themes"), QStandardPaths::LocateDirectory);
     QDir dir(themesBaseDir);
+
+    // If the standard location is not writable by the root-privileged process,
+    // reassign the path to the local directory.
+    if (!QFileInfo(themesBaseDir).isWritable()) {
+        themesBaseDir = QStringLiteral("/usr/local/share/sddm/themes");
+        dir.setPath(themesBaseDir);
+    }
+
+    // Create the destination directory if it doesn't exist.
     if (!dir.exists()) {
-        return ActionReply::HelperErrorReply();
+        if (!dir.mkpath(themesBaseDir)) {
+            return ActionReply::HelperErrorReply();
+        }
     }
 
     QByteArray themeData = theme.readAll();
openSUSE Build Service is sponsored by