fix(config): ensure trailing slash

This commit is contained in:
Lemmy
2026-03-19 07:53:03 -04:00
parent 5eb8b9cbcb
commit e8bca17225
6 changed files with 22 additions and 18 deletions
+2 -3
View File
@@ -1,5 +1,6 @@
import QtQuick
import Quickshell
import qs.Commons
QtObject {
id: root
@@ -7,9 +8,7 @@ QtObject {
function migrate(adapter, logger, rawJson) {
logger.i("Migration44", "Updating PAM pam/password.conf");
// Copying logic from Settings.qml to avoid dependency on it
const shellName = "noctalia";
const configDir = Quickshell.env("NOCTALIA_CONFIG_DIR") || (Quickshell.env("XDG_CONFIG_HOME") || Quickshell.env("HOME") + "/.config") + "/" + shellName + "/";
const configDir = Settings.configDir;
const pamConfigDir = configDir + "pam";
const pamConfigFile = pamConfigDir + "/password.conf";
const pamConfigDirEsc = pamConfigDir.replace(/'/g, "'\\''");
+2 -2
View File
@@ -1,5 +1,6 @@
import QtQuick
import Quickshell
import qs.Commons
QtObject {
id: root
@@ -7,8 +8,7 @@ QtObject {
function migrate(adapter, logger, rawJson) {
logger.i("Migration46", "Removing legacy PAM configuration file");
const shellName = "noctalia";
const configDir = Quickshell.env("NOCTALIA_CONFIG_DIR") || (Quickshell.env("XDG_CONFIG_HOME") || Quickshell.env("HOME") + "/.config") + "/" + shellName + "/";
const configDir = Settings.configDir;
const pamConfigDir = configDir + "pam";
// Remove the entire pam directory if it exists
const script = `rm -rf '${pamConfigDir}'`;
+2 -4
View File
@@ -1,5 +1,6 @@
import QtQuick
import Quickshell
import qs.Commons
QtObject {
id: root
@@ -7,10 +8,7 @@ QtObject {
function migrate(adapter, logger, rawJson) {
logger.i("Migration47", "Removing network_stats.json cache");
// Remove the network_stats.json cache file (no longer used - autoscaling from history now)
const shellName = "noctalia";
const cacheDir = Quickshell.env("NOCTALIA_CACHE_DIR") || (Quickshell.env("XDG_CACHE_HOME") || Quickshell.env("HOME") + "/.cache") + "/" + shellName + "/";
const networkStatsFile = cacheDir + "network_stats.json";
const networkStatsFile = Settings.cacheDir + "network_stats.json";
Quickshell.execDetached(["rm", "-f", networkStatsFile]);
logger.d("Migration47", "Removed network_stats.json");
+2 -1
View File
@@ -1,5 +1,6 @@
import QtQuick
import Quickshell
import qs.Commons
QtObject {
id: root
@@ -8,7 +9,7 @@ QtObject {
logger.i("Settings", "Migrating settings to v56 (Color Scheme Migration)");
const scriptPath = Quickshell.shellDir + "/Scripts/python/src/theming/migrate-colorschemes.py";
const configDir = Quickshell.env("NOCTALIA_CONFIG_DIR") || (Quickshell.env("XDG_CONFIG_HOME") || Quickshell.env("HOME") + "/.config") + "/noctalia";
const configDir = Settings.configDir;
logger.i("Settings", `Running color scheme migration script: ${scriptPath} with configDir: ${configDir}`);
+10 -3
View File
@@ -28,8 +28,9 @@ Singleton {
readonly property int settingsVersion: 59
property bool isDebug: Quickshell.env("NOCTALIA_DEBUG") === "1"
readonly property string shellName: "noctalia"
readonly property string configDir: Quickshell.env("NOCTALIA_CONFIG_DIR") || (Quickshell.env("XDG_CONFIG_HOME") || Quickshell.env("HOME") + "/.config") + "/" + shellName + "/"
readonly property string cacheDir: Quickshell.env("NOCTALIA_CACHE_DIR") || (Quickshell.env("XDG_CACHE_HOME") || Quickshell.env("HOME") + "/.cache") + "/" + shellName + "/"
readonly property string configDir: ensureTrailingSlash(Quickshell.env("NOCTALIA_CONFIG_DIR") || (Quickshell.env("XDG_CONFIG_HOME") || Quickshell.env("HOME") + "/.config") + "/" + shellName + "/")
readonly property string cacheDir: ensureTrailingSlash(Quickshell.env("NOCTALIA_CACHE_DIR") || (Quickshell.env("XDG_CACHE_HOME") || Quickshell.env("HOME") + "/.cache") + "/" + shellName + "/")
readonly property string settingsFile: Quickshell.env("NOCTALIA_SETTINGS_FILE") || (configDir + "settings.json")
readonly property string defaultLocation: "Tokyo"
readonly property string defaultAvatar: Quickshell.env("HOME") + "/.face"
@@ -777,7 +778,13 @@ Singleton {
}
// -----------------------------------------------------
// Function to preprocess paths by expanding "~" to user's home directory
// Preprocess paths by adding trailing "/"
function ensureTrailingSlash(path) {
return path.endsWith("/") ? path : path + "/";
}
// -----------------------------------------------------
// Preprocess paths by expanding "~" to user's home directory
function preprocessPath(path) {
if (typeof path !== "string" || path === "") {
return path;
+4 -5
View File
@@ -121,15 +121,14 @@ async def refresh_theme():
async def get_config_dir() -> Path:
# 1. project-specific override
if value := os.environ.get("NOCTALIA_CONFIG_DIR"):
return Path(value).expanduser()
# Returns the XDG config home (e.g. ~/.config)
# GTK config lives at ~/.config/gtk-3.0/ and ~/.config/gtk-4.0/.
# 2. XDG standard
# 1. XDG standard
if value := os.environ.get("XDG_CONFIG_HOME"):
return Path(value).expanduser()
# 3. fallback
# 2. fallback
return Path.home() / ".config"