feat(flake): write settings to a fallback path

This commit is contained in:
Matan Bendix Shenhav
2025-09-30 00:11:03 +02:00
parent c92478d27d
commit df35589328
2 changed files with 26 additions and 3 deletions
+22 -2
View File
@@ -71,7 +71,13 @@ Singleton {
id: saveTimer
running: false
interval: 1000
onTriggered: settingsFileView.writeAdapter()
onTriggered: {
settingsFileView.writeAdapter()
// Write to fallback location if set
if (Quickshell.env("NOCTALIA_SETTINGS_FALLBACK")) {
settingsFallbackFileView.writeAdapter()
}
}
}
FileView {
@@ -101,11 +107,25 @@ Singleton {
}
}
onLoadFailed: function (error) {
if (error.toString().includes("No such file") || error === 2)
if (error.toString().includes("No such file") || error === 2) {
// File doesn't exist, create it with default values
writeAdapter()
// Also write to fallback if set
if (Quickshell.env("NOCTALIA_SETTINGS_FALLBACK")) {
settingsFallbackFileView.writeAdapter()
}
}
}
}
// Fallback FileView for writing settings to alternate location
FileView {
id: settingsFallbackFileView
path: Quickshell.env("NOCTALIA_SETTINGS_FALLBACK") || ""
adapter: Quickshell.env("NOCTALIA_SETTINGS_FALLBACK") ? adapter : null
printErrors: false
watchChanges: false
}
JsonAdapter {
id: adapter
+4 -1
View File
@@ -277,7 +277,10 @@
RestartSec = 3;
TimeoutStartSec = 10;
TimeoutStopSec = 5;
Environment = [ "PATH=${config.system.path}/bin" ];
Environment = [
"PATH=${config.system.path}/bin"
"NOCTALIA_SETTINGS_FALLBACK=%h/.config/noctalia/gui-settings.json"
];
};
};