From 0c82ce9704c8063be8d8f60443071c91943eb68c Mon Sep 17 00:00:00 2001 From: Sumit Pathak Date: Tue, 29 Apr 2025 05:46:56 +0530 Subject: [PATCH] Fix wallpaper path handling with spaces (#908) * Fix wallpaper path handling with spaces * fix linting errors --------- Co-authored-by: Jas Singh --- src/components/settings/shared/inputs/wallpaper.tsx | 2 +- src/scss/optionsTrackers.ts | 2 +- src/services/Wallpaper.ts | 4 ++-- src/services/matugen/index.ts | 6 ++++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/components/settings/shared/inputs/wallpaper.tsx b/src/components/settings/shared/inputs/wallpaper.tsx index 7cb788c..238a18d 100644 --- a/src/components/settings/shared/inputs/wallpaper.tsx +++ b/src/components/settings/shared/inputs/wallpaper.tsx @@ -9,7 +9,7 @@ export const WallpaperInputter = ( return ( { - const newValue: string = self.get_uri()!.replace('file://', ''); + const newValue: string = decodeURIComponent(self.get_uri()!.replace('file://', '')); opt.set(newValue as T); if (options.wallpaper.enable.get()) { Wallpaper.setWallpaper(newValue); diff --git a/src/scss/optionsTrackers.ts b/src/scss/optionsTrackers.ts index a605477..53a004e 100644 --- a/src/scss/optionsTrackers.ts +++ b/src/scss/optionsTrackers.ts @@ -37,7 +37,7 @@ export const initializeTrackers = (resetCssFunc: () => void): void => { } if (options.wallpaper.pywal.get() && dependencies('wal')) { const wallpaperPath = options.wallpaper.image.get(); - bash(`wal -i ${wallpaperPath}`); + bash(`wal -i "${wallpaperPath}"`); } }); }; diff --git a/src/services/Wallpaper.ts b/src/services/Wallpaper.ts index 2748b9a..16fd1da 100644 --- a/src/services/Wallpaper.ts +++ b/src/services/Wallpaper.ts @@ -30,7 +30,7 @@ class Wallpaper extends GObject.Object { '60', '--transition-pos', cursorPosition.replace(' ', ''), - WP, + `"${WP}"`, ].join(' '); sh(transitionCmd) @@ -50,7 +50,7 @@ class Wallpaper extends GObject.Object { this.#blockMonitor = true; try { - await sh(`cp ${path} ${WP}`); + await sh(`cp "${path}" "${WP}"`); this.#wallpaper(); } catch (error) { console.error('Error setting wallpaper:', error); diff --git a/src/services/matugen/index.ts b/src/services/matugen/index.ts index 5c0b139..18db9e0 100644 --- a/src/services/matugen/index.ts +++ b/src/services/matugen/index.ts @@ -30,9 +30,11 @@ export async function generateMatugenColors(): Promise 1 ? 1 : contrast.get() < -1 ? -1 : contrast.get(); const contents = await bash( - `matugen image --dry-run -q ${wallpaperPath} -t scheme-${scheme_type.get()} --contrast ${normalizedContrast} --json hex`, + `matugen image --dry-run -q "${wallpaperPath}" -t scheme-${scheme_type.get()} --contrast ${normalizedContrast} --json hex`, + ); + await bash( + `matugen image -q "${wallpaperPath}" -t scheme-${scheme_type.get()} --contrast ${normalizedContrast}`, ); - await bash(`matugen image -q ${wallpaperPath} -t scheme-${scheme_type.get()} --contrast ${normalizedContrast}`); return JSON.parse(contents).colors[options.theme.matugen_settings.mode.get()]; } catch (error) {