Files
LockScreenWallpaper/plugins/src/lib.rs
T
Christoph 73f8599c7f feat(wallpaper): add apply_wallpaper workflow and rotation worker
Adds a new apply_wallpaper command and its plumbing across
desktop, mobile, and Android. A WorkManager-based rotation
worker handles applying wallpapers in the background. Wallpaper
state now tracks currentId and imageIds for precise control.

- Introduced apply_wallpaper command across desktop, mobile and Android
- Added WorkManager-based rotation worker to apply wallpapers in the
  background
- Extended wallpaper state with currentId and imageIds and updated schemas/permissions
2026-08-21 23:15:00 +02:00

68 lines
1.7 KiB
Rust

use tauri::{
plugin::{Builder, TauriPlugin},
Manager, Runtime,
};
pub use models::*;
#[cfg(desktop)]
mod desktop;
#[cfg(mobile)]
mod mobile;
mod commands;
mod error;
mod models;
pub use error::{Error, Result};
#[cfg(desktop)]
use desktop::Wallpaper;
#[cfg(mobile)]
use mobile::Wallpaper;
/// Extensions to [`tauri::App`], [`tauri::AppHandle`] and [`tauri::Window`] to access the wallpaper APIs.
pub trait WallpaperExt<R: Runtime> {
fn wallpaper(&self) -> &Wallpaper<R>;
}
impl<R: Runtime, T: Manager<R>> crate::WallpaperExt<R> for T {
fn wallpaper(&self) -> &Wallpaper<R> {
self.state::<Wallpaper<R>>().inner()
}
}
/// Initializes the plugin.
pub fn init<R: Runtime>() -> TauriPlugin<R> {
Builder::new("wallpaper")
.invoke_handler(tauri::generate_handler![
commands::get_state,
commands::get_gallery,
commands::select_images,
commands::delete_image,
commands::get_image_ids,
commands::delete_images,
commands::set_image_crop,
commands::set_setting,
commands::set_interval,
commands::next_wallpaper,
commands::apply_wallpaper,
commands::get_immich_connection,
commands::connect_immich,
commands::disconnect_immich,
commands::get_immich_albums,
commands::get_immich_assets,
commands::import_immich_assets,
commands::get_immich_import_progress
])
.setup(|app, api| {
#[cfg(mobile)]
let wallpaper = mobile::init(app, api)?;
#[cfg(desktop)]
let wallpaper = desktop::init(app, api)?;
app.manage(wallpaper);
Ok(())
})
.build()
}