Adjust Linux wallpaper test mode
This commit is contained in:
45
dist/main/system_handlers.js
vendored
45
dist/main/system_handlers.js
vendored
@@ -221,18 +221,41 @@ function registerSystemHandlers() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (os.platform() === 'linux') {
|
if (os.platform() === 'linux') {
|
||||||
let img_path = imagePath ? (0, file_utils_1.expandPath)(imagePath) : null;
|
// Dev test mode: never touch the desktop on Linux. Running gsettings during
|
||||||
if (!img_path && url) {
|
// development would reset the dev workstation monitors on every test cycle.
|
||||||
const result = await download_wallpaper_image(url, 'wallpaper_primary');
|
// Return what would have run so the Svelte side can show a debug popup.
|
||||||
if (!result.success || !result.path)
|
const would_run = [];
|
||||||
return { success: false, error: result.error };
|
const cache_dir = wallpaper_cache_dir;
|
||||||
img_path = result.path;
|
if (!imagePath && !url && !url_external) {
|
||||||
}
|
|
||||||
if (!img_path)
|
|
||||||
return { success: false, error: 'No image source provided' };
|
return { success: false, error: 'No image source provided' };
|
||||||
if (!fs.existsSync(img_path))
|
}
|
||||||
return { success: false, error: 'Image file not found' };
|
if (imagePath) {
|
||||||
return await runExec(`gsettings set org.gnome.desktop.background picture-uri "file://${img_path}"`);
|
const clean = (0, file_utils_1.expandPath)(imagePath);
|
||||||
|
if (!fs.existsSync(clean))
|
||||||
|
return { success: false, error: 'Image file not found' };
|
||||||
|
}
|
||||||
|
if (url)
|
||||||
|
would_run.push(`download: ${url}\n → ${path.join(cache_dir, 'wallpaper_primary.jpg')}`);
|
||||||
|
if (url_external)
|
||||||
|
would_run.push(`download: ${url_external}\n → ${path.join(cache_dir, 'wallpaper_external.jpg')}`);
|
||||||
|
if (imagePath) {
|
||||||
|
would_run.push(`gsettings set org.gnome.desktop.background picture-uri "file://${(0, file_utils_1.expandPath)(imagePath)}"`);
|
||||||
|
}
|
||||||
|
else if (url) {
|
||||||
|
would_run.push(`gsettings set org.gnome.desktop.background picture-uri "file://${path.join(cache_dir, 'wallpaper_primary.jpg')}"`);
|
||||||
|
}
|
||||||
|
if (url_external) {
|
||||||
|
would_run.push(`(external display: gsettings has no per-display wallpaper support)`);
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
linux_test_mode: true,
|
||||||
|
platform: 'linux',
|
||||||
|
display,
|
||||||
|
url: url ?? null,
|
||||||
|
url_external: url_external ?? null,
|
||||||
|
would_run
|
||||||
|
};
|
||||||
}
|
}
|
||||||
return { success: false, error: 'Platform not supported' };
|
return { success: false, error: 'Platform not supported' };
|
||||||
});
|
});
|
||||||
|
|||||||
2
dist/main/system_handlers.js.map
vendored
2
dist/main/system_handlers.js.map
vendored
File diff suppressed because one or more lines are too long
@@ -177,18 +177,42 @@ export function registerSystemHandlers() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (os.platform() === 'linux') {
|
if (os.platform() === 'linux') {
|
||||||
let img_path: string | null = imagePath ? expandPath(imagePath) : null;
|
// Dev test mode: never touch the desktop on Linux. Running gsettings during
|
||||||
|
// development would reset the dev workstation monitors on every test cycle.
|
||||||
|
// Return what would have run so the Svelte side can show a debug popup.
|
||||||
|
const would_run: string[] = [];
|
||||||
|
const cache_dir = wallpaper_cache_dir;
|
||||||
|
|
||||||
if (!img_path && url) {
|
if (!imagePath && !url && !url_external) {
|
||||||
const result = await download_wallpaper_image(url, 'wallpaper_primary');
|
return { success: false, error: 'No image source provided' };
|
||||||
if (!result.success || !result.path) return { success: false, error: result.error };
|
|
||||||
img_path = result.path;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!img_path) return { success: false, error: 'No image source provided' };
|
if (imagePath) {
|
||||||
if (!fs.existsSync(img_path)) return { success: false, error: 'Image file not found' };
|
const clean = expandPath(imagePath);
|
||||||
|
if (!fs.existsSync(clean)) return { success: false, error: 'Image file not found' };
|
||||||
|
}
|
||||||
|
|
||||||
return await runExec(`gsettings set org.gnome.desktop.background picture-uri "file://${img_path}"`);
|
if (url) would_run.push(`download: ${url}\n → ${path.join(cache_dir, 'wallpaper_primary.jpg')}`);
|
||||||
|
if (url_external) would_run.push(`download: ${url_external}\n → ${path.join(cache_dir, 'wallpaper_external.jpg')}`);
|
||||||
|
|
||||||
|
if (imagePath) {
|
||||||
|
would_run.push(`gsettings set org.gnome.desktop.background picture-uri "file://${expandPath(imagePath)}"`);
|
||||||
|
} else if (url) {
|
||||||
|
would_run.push(`gsettings set org.gnome.desktop.background picture-uri "file://${path.join(cache_dir, 'wallpaper_primary.jpg')}"`);
|
||||||
|
}
|
||||||
|
if (url_external) {
|
||||||
|
would_run.push(`(external display: gsettings has no per-display wallpaper support)`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
linux_test_mode: true,
|
||||||
|
platform: 'linux',
|
||||||
|
display,
|
||||||
|
url: url ?? null,
|
||||||
|
url_external: url_external ?? null,
|
||||||
|
would_run
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return { success: false, error: 'Platform not supported' };
|
return { success: false, error: 'Platform not supported' };
|
||||||
|
|||||||
Reference in New Issue
Block a user