mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
fix(config): ensure trailing slash
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import QtQuick
|
import QtQuick
|
||||||
import Quickshell
|
import Quickshell
|
||||||
|
import qs.Commons
|
||||||
|
|
||||||
QtObject {
|
QtObject {
|
||||||
id: root
|
id: root
|
||||||
@@ -7,9 +8,7 @@ QtObject {
|
|||||||
function migrate(adapter, logger, rawJson) {
|
function migrate(adapter, logger, rawJson) {
|
||||||
logger.i("Migration44", "Updating PAM pam/password.conf");
|
logger.i("Migration44", "Updating PAM pam/password.conf");
|
||||||
|
|
||||||
// Copying logic from Settings.qml to avoid dependency on it
|
const configDir = Settings.configDir;
|
||||||
const shellName = "noctalia";
|
|
||||||
const configDir = Quickshell.env("NOCTALIA_CONFIG_DIR") || (Quickshell.env("XDG_CONFIG_HOME") || Quickshell.env("HOME") + "/.config") + "/" + shellName + "/";
|
|
||||||
const pamConfigDir = configDir + "pam";
|
const pamConfigDir = configDir + "pam";
|
||||||
const pamConfigFile = pamConfigDir + "/password.conf";
|
const pamConfigFile = pamConfigDir + "/password.conf";
|
||||||
const pamConfigDirEsc = pamConfigDir.replace(/'/g, "'\\''");
|
const pamConfigDirEsc = pamConfigDir.replace(/'/g, "'\\''");
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import QtQuick
|
import QtQuick
|
||||||
import Quickshell
|
import Quickshell
|
||||||
|
import qs.Commons
|
||||||
|
|
||||||
QtObject {
|
QtObject {
|
||||||
id: root
|
id: root
|
||||||
@@ -7,8 +8,7 @@ QtObject {
|
|||||||
function migrate(adapter, logger, rawJson) {
|
function migrate(adapter, logger, rawJson) {
|
||||||
logger.i("Migration46", "Removing legacy PAM configuration file");
|
logger.i("Migration46", "Removing legacy PAM configuration file");
|
||||||
|
|
||||||
const shellName = "noctalia";
|
const configDir = Settings.configDir;
|
||||||
const configDir = Quickshell.env("NOCTALIA_CONFIG_DIR") || (Quickshell.env("XDG_CONFIG_HOME") || Quickshell.env("HOME") + "/.config") + "/" + shellName + "/";
|
|
||||||
const pamConfigDir = configDir + "pam";
|
const pamConfigDir = configDir + "pam";
|
||||||
// Remove the entire pam directory if it exists
|
// Remove the entire pam directory if it exists
|
||||||
const script = `rm -rf '${pamConfigDir}'`;
|
const script = `rm -rf '${pamConfigDir}'`;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import QtQuick
|
import QtQuick
|
||||||
import Quickshell
|
import Quickshell
|
||||||
|
import qs.Commons
|
||||||
|
|
||||||
QtObject {
|
QtObject {
|
||||||
id: root
|
id: root
|
||||||
@@ -7,10 +8,7 @@ QtObject {
|
|||||||
function migrate(adapter, logger, rawJson) {
|
function migrate(adapter, logger, rawJson) {
|
||||||
logger.i("Migration47", "Removing network_stats.json cache");
|
logger.i("Migration47", "Removing network_stats.json cache");
|
||||||
|
|
||||||
// Remove the network_stats.json cache file (no longer used - autoscaling from history now)
|
const networkStatsFile = Settings.cacheDir + "network_stats.json";
|
||||||
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";
|
|
||||||
Quickshell.execDetached(["rm", "-f", networkStatsFile]);
|
Quickshell.execDetached(["rm", "-f", networkStatsFile]);
|
||||||
|
|
||||||
logger.d("Migration47", "Removed network_stats.json");
|
logger.d("Migration47", "Removed network_stats.json");
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import QtQuick
|
import QtQuick
|
||||||
import Quickshell
|
import Quickshell
|
||||||
|
import qs.Commons
|
||||||
|
|
||||||
QtObject {
|
QtObject {
|
||||||
id: root
|
id: root
|
||||||
@@ -8,7 +9,7 @@ QtObject {
|
|||||||
logger.i("Settings", "Migrating settings to v56 (Color Scheme Migration)");
|
logger.i("Settings", "Migrating settings to v56 (Color Scheme Migration)");
|
||||||
|
|
||||||
const scriptPath = Quickshell.shellDir + "/Scripts/python/src/theming/migrate-colorschemes.py";
|
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}`);
|
logger.i("Settings", `Running color scheme migration script: ${scriptPath} with configDir: ${configDir}`);
|
||||||
|
|
||||||
|
|||||||
+10
-3
@@ -28,8 +28,9 @@ Singleton {
|
|||||||
readonly property int settingsVersion: 59
|
readonly property int settingsVersion: 59
|
||||||
property bool isDebug: Quickshell.env("NOCTALIA_DEBUG") === "1"
|
property bool isDebug: Quickshell.env("NOCTALIA_DEBUG") === "1"
|
||||||
readonly property string shellName: "noctalia"
|
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 configDir: ensureTrailingSlash(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 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 settingsFile: Quickshell.env("NOCTALIA_SETTINGS_FILE") || (configDir + "settings.json")
|
||||||
readonly property string defaultLocation: "Tokyo"
|
readonly property string defaultLocation: "Tokyo"
|
||||||
readonly property string defaultAvatar: Quickshell.env("HOME") + "/.face"
|
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) {
|
function preprocessPath(path) {
|
||||||
if (typeof path !== "string" || path === "") {
|
if (typeof path !== "string" || path === "") {
|
||||||
return path;
|
return path;
|
||||||
|
|||||||
@@ -121,15 +121,14 @@ async def refresh_theme():
|
|||||||
|
|
||||||
|
|
||||||
async def get_config_dir() -> Path:
|
async def get_config_dir() -> Path:
|
||||||
# 1. project-specific override
|
# Returns the XDG config home (e.g. ~/.config)
|
||||||
if value := os.environ.get("NOCTALIA_CONFIG_DIR"):
|
# GTK config lives at ~/.config/gtk-3.0/ and ~/.config/gtk-4.0/.
|
||||||
return Path(value).expanduser()
|
|
||||||
|
|
||||||
# 2. XDG standard
|
# 1. XDG standard
|
||||||
if value := os.environ.get("XDG_CONFIG_HOME"):
|
if value := os.environ.get("XDG_CONFIG_HOME"):
|
||||||
return Path(value).expanduser()
|
return Path(value).expanduser()
|
||||||
|
|
||||||
# 3. fallback
|
# 2. fallback
|
||||||
return Path.home() / ".config"
|
return Path.home() / ".config"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user