From 2e95c6c98a0544618d9d27fb2f8cbd60a67ba7da Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Mon, 23 Feb 2026 03:19:28 -0600 Subject: [PATCH] feat(auto-theme): add V2 commands for theme generation and system detection Six new commands: - v2_detect_desktop_environment: detect current DE - v2_get_system_wallpaper: get wallpaper path - v2_get_system_accent_color: get DE accent color - v2_generate_theme_from_image: generate theme from any image - v2_generate_theme_from_wallpaper: generate theme from system wallpaper - v2_extract_palette: extract color palette for preview All are pure functions (no State needed), registered in invoke_handler. cc --- src-tauri/src/commands_v2.rs | 47 ++++++++++++++++++++++++++++++++++++ src-tauri/src/lib.rs | 7 ++++++ 2 files changed, 54 insertions(+) diff --git a/src-tauri/src/commands_v2.rs b/src-tauri/src/commands_v2.rs index d6c1f2cae..c3e1e789e 100644 --- a/src-tauri/src/commands_v2.rs +++ b/src-tauri/src/commands_v2.rs @@ -10125,3 +10125,50 @@ pub async fn v2_dynamic_suggest_raw( .await .map_err(|e| format!("Failed to fetch raw dynamic suggestions: {}", e)) } + +// ── Auto-Theme commands ───────────────────────────────────────────────────── + +#[tauri::command] +pub fn v2_detect_desktop_environment() -> crate::auto_theme::system::DesktopEnvironment { + crate::auto_theme::system::detect_desktop_environment() +} + +#[tauri::command] +pub fn v2_get_system_wallpaper() -> Result { + crate::auto_theme::system::get_system_wallpaper() +} + +#[tauri::command] +pub fn v2_get_system_accent_color() -> Result { + crate::auto_theme::system::get_system_accent_color() +} + +#[tauri::command] +#[allow(non_snake_case)] +pub fn v2_generate_theme_from_image( + imagePath: String, +) -> Result { + let palette = crate::auto_theme::palette::extract_palette(&imagePath)?; + Ok(crate::auto_theme::generator::generate_theme( + &palette, + &imagePath, + )) +} + +#[tauri::command] +pub fn v2_generate_theme_from_wallpaper() -> Result { + let wallpaper = crate::auto_theme::system::get_system_wallpaper()?; + let palette = crate::auto_theme::palette::extract_palette(&wallpaper)?; + Ok(crate::auto_theme::generator::generate_theme( + &palette, + &wallpaper, + )) +} + +#[tauri::command] +#[allow(non_snake_case)] +pub fn v2_extract_palette( + imagePath: String, +) -> Result { + crate::auto_theme::palette::extract_palette(&imagePath) +} diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 5a70b934b..a8d83f92f 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -1104,6 +1104,13 @@ pub fn run() { commands_v2::v2_check_qobuzapp_handler, commands_v2::v2_register_qobuzapp_handler, commands_v2::v2_deregister_qobuzapp_handler, + // Auto-theme + commands_v2::v2_detect_desktop_environment, + commands_v2::v2_get_system_wallpaper, + commands_v2::v2_get_system_accent_color, + commands_v2::v2_generate_theme_from_image, + commands_v2::v2_generate_theme_from_wallpaper, + commands_v2::v2_extract_palette, ]) .run(tauri::generate_context!()) .expect("error while running tauri application");