From d53a3d8de2a54ddf5ea6894c20247e6669f47317 Mon Sep 17 00:00:00 2001 From: Ly-sec Date: Sat, 29 Nov 2025 13:36:37 +0100 Subject: [PATCH] SchemeDownloader: add support for spaces in names --- .../Tabs/ColorScheme/SchemeDownloader.qml | 18 ++++++++++++++---- Services/Theming/TemplateProcessor.qml | 9 +++++++-- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/Modules/Panels/Settings/Tabs/ColorScheme/SchemeDownloader.qml b/Modules/Panels/Settings/Tabs/ColorScheme/SchemeDownloader.qml index f064424c..7fe8d73c 100644 --- a/Modules/Panels/Settings/Tabs/ColorScheme/SchemeDownloader.qml +++ b/Modules/Panels/Settings/Tabs/ColorScheme/SchemeDownloader.qml @@ -241,9 +241,14 @@ Popup { // Rate limit hit - try to use cache if available downloadError = I18n.tr("settings.color-scheme.download.error.rate-limit"); Logger.w("ColorSchemeDownload", downloadError); - if (schemesCacheAdapter.schemes && schemesCacheAdapter.schemes.length > 0) { - availableSchemes = schemesCacheAdapter.schemes; - Logger.i("ColorSchemeDownload", "Using cached schemes due to rate limit"); + if (typeof ShellState !== 'undefined' && ShellState.isLoaded) { + const cacheData = ShellState.getColorSchemesList(); + const cachedSchemes = cacheData.schemes || []; + if (cachedSchemes.length > 0) { + availableSchemes = cachedSchemes; + hasInitialData = true; + Logger.i("ColorSchemeDownload", "Using cached schemes due to rate limit"); + } } } else { downloadError = I18n.tr("settings.color-scheme.download.error.api-error", { @@ -740,7 +745,12 @@ Popup { enabled: !fetching && !downloading onClicked: { // Force refresh by clearing cache timestamp and fetching directly from API - schemesCacheAdapter.timestamp = 0; + if (typeof ShellState !== 'undefined' && ShellState.isLoaded) { + ShellState.setColorSchemesList({ + schemes: [], + timestamp: 0 + }); + } // Fetch directly from API to avoid cache check delay fetchAvailableSchemesFromAPI(); } diff --git a/Services/Theming/TemplateProcessor.qml b/Services/Theming/TemplateProcessor.qml index 984f219c..3afddf0a 100644 --- a/Services/Theming/TemplateProcessor.qml +++ b/Services/Theming/TemplateProcessor.qml @@ -329,6 +329,11 @@ Singleton { // ================================================================================ // TERMINAL THEMES (predefined schemes use pre-rendered files) // ================================================================================ + function escapeShellPath(path) { + // Escape single quotes by ending the quoted string, adding an escaped quote, and starting a new quoted string + return "'" + path.replace(/'/g, "'\\''") + "'"; + } + function handleTerminalThemes(mode) { const commands = []; const homeDir = Quickshell.env("HOME"); @@ -339,8 +344,8 @@ Singleton { const outputDir = outputPath.substring(0, outputPath.lastIndexOf('/')); const templatePath = getTerminalColorsTemplate(terminal, mode); - commands.push(`mkdir -p ${outputDir}`); - commands.push(`cp -f ${templatePath} ${outputPath}`); + commands.push(`mkdir -p ${escapeShellPath(outputDir)}`); + commands.push(`cp -f ${escapeShellPath(templatePath)} ${escapeShellPath(outputPath)}`); commands.push(`${TemplateRegistry.colorsApplyScript} ${terminal}`); } });