Fix wallpaper path handling with spaces (#908)

* Fix wallpaper path handling with spaces

* fix linting errors

---------

Co-authored-by: Jas Singh <jaskiratpal.singh@outlook.com>
This commit is contained in:
Sumit Pathak
2025-04-29 05:46:56 +05:30
committed by GitHub
parent 07a990f1f8
commit 0c82ce9704
4 changed files with 8 additions and 6 deletions

View File

@@ -9,7 +9,7 @@ export const WallpaperInputter = <T extends string | number | boolean | object>(
return ( return (
<FileChooserButton <FileChooserButton
onFileSet={(self) => { onFileSet={(self) => {
const newValue: string = self.get_uri()!.replace('file://', ''); const newValue: string = decodeURIComponent(self.get_uri()!.replace('file://', ''));
opt.set(newValue as T); opt.set(newValue as T);
if (options.wallpaper.enable.get()) { if (options.wallpaper.enable.get()) {
Wallpaper.setWallpaper(newValue); Wallpaper.setWallpaper(newValue);

View File

@@ -37,7 +37,7 @@ export const initializeTrackers = (resetCssFunc: () => void): void => {
} }
if (options.wallpaper.pywal.get() && dependencies('wal')) { if (options.wallpaper.pywal.get() && dependencies('wal')) {
const wallpaperPath = options.wallpaper.image.get(); const wallpaperPath = options.wallpaper.image.get();
bash(`wal -i ${wallpaperPath}`); bash(`wal -i "${wallpaperPath}"`);
} }
}); });
}; };

View File

@@ -30,7 +30,7 @@ class Wallpaper extends GObject.Object {
'60', '60',
'--transition-pos', '--transition-pos',
cursorPosition.replace(' ', ''), cursorPosition.replace(' ', ''),
WP, `"${WP}"`,
].join(' '); ].join(' ');
sh(transitionCmd) sh(transitionCmd)
@@ -50,7 +50,7 @@ class Wallpaper extends GObject.Object {
this.#blockMonitor = true; this.#blockMonitor = true;
try { try {
await sh(`cp ${path} ${WP}`); await sh(`cp "${path}" "${WP}"`);
this.#wallpaper(); this.#wallpaper();
} catch (error) { } catch (error) {
console.error('Error setting wallpaper:', error); console.error('Error setting wallpaper:', error);

View File

@@ -30,9 +30,11 @@ export async function generateMatugenColors(): Promise<MatugenColors | undefined
const normalizedContrast = contrast.get() > 1 ? 1 : contrast.get() < -1 ? -1 : contrast.get(); const normalizedContrast = contrast.get() > 1 ? 1 : contrast.get() < -1 ? -1 : contrast.get();
const contents = await bash( 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()]; return JSON.parse(contents).colors[options.theme.matugen_settings.mode.get()];
} catch (error) { } catch (error) {