From 38928abab79cb2cc76c1a01ee2e3758f40df0221 Mon Sep 17 00:00:00 2001 From: Ly-sec Date: Mon, 8 Sep 2025 07:51:49 +0200 Subject: [PATCH] Fix first start noctalia settings & color creation --- Commons/Color.qml | 9 ++++++++- Commons/Settings.qml | 28 +++++++++++++++++----------- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/Commons/Color.qml b/Commons/Color.qml index d7636a0..fa2912e 100644 --- a/Commons/Color.qml +++ b/Commons/Color.qml @@ -102,7 +102,7 @@ Singleton { // FileView to load custom colors data from colors.json FileView { id: customColorsFile - path: Settings.configDir + "colors.json" + path: Settings.directoriesCreated ? (Settings.configDir + "colors.json") : "" watchChanges: true onFileChanged: { Logger.log("Color", "Reloading colors from disk") @@ -112,6 +112,13 @@ Singleton { Logger.log("Color", "Writing colors to disk") writeAdapter() } + + // Trigger initial load when path changes from empty to actual path + onPathChanged: { + if (path === Settings.configDir + "colors.json") { + reload() + } + } onLoadFailed: function (error) { if (error.toString().includes("No such file") || error === 2) { // File doesn't exist, create it with default values diff --git a/Commons/Settings.qml b/Commons/Settings.qml index 9c2268f..ef38b47 100644 --- a/Commons/Settings.qml +++ b/Commons/Settings.qml @@ -31,6 +31,7 @@ Singleton { readonly property alias data: adapter property bool isLoaded: false + property bool directoriesCreated: false // Signal emitted when settings are loaded after startupcale changes signal settingsLoaded @@ -176,14 +177,15 @@ Singleton { } // ----------------------------------------------------- - Item { - Component.onCompleted: { - - // ensure settings dir exists - Quickshell.execDetached(["mkdir", "-p", configDir]) - Quickshell.execDetached(["mkdir", "-p", cacheDir]) - Quickshell.execDetached(["mkdir", "-p", cacheDirImages]) - } + // Ensure directories exist before FileView tries to read files + Component.onCompleted: { + // ensure settings dir exists + Quickshell.execDetached(["mkdir", "-p", configDir]) + Quickshell.execDetached(["mkdir", "-p", cacheDir]) + Quickshell.execDetached(["mkdir", "-p", cacheDirImages]) + + // Mark directories as created and trigger file loading + directoriesCreated = true } // Don't write settings to disk immediately @@ -197,12 +199,16 @@ Singleton { FileView { id: settingsFileView - path: settingsFile + path: directoriesCreated ? settingsFile : "" watchChanges: true onFileChanged: reload() onAdapterUpdated: saveTimer.start() - Component.onCompleted: function () { - reload() + + // Trigger initial load when path changes from empty to actual path + onPathChanged: { + if (path === settingsFile) { + reload() + } } onLoaded: function () { if (!isLoaded) {