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
This commit is contained in:
2026-08-21 23:15:00 +02:00
parent e494b17117
commit 73f8599c7f
25 changed files with 266 additions and 49 deletions
+4
View File
@@ -71,6 +71,10 @@ pub(crate) async fn set_interval<R: Runtime>(app: AppHandle<R>, minutes: usize)
pub(crate) async fn next_wallpaper<R: Runtime>(app: AppHandle<R>) -> Result<WallpaperState> {
app.wallpaper().next_wallpaper()
}
#[command]
pub(crate) async fn apply_wallpaper<R: Runtime>(app: AppHandle<R>, id: String) -> Result<WallpaperState> {
app.wallpaper().apply_wallpaper(ApplyWallpaperRequest { id })
}
#[command]
pub(crate) async fn get_immich_connection<R: Runtime>(app: AppHandle<R>) -> Result<ImmichConnection> {
+11
View File
@@ -22,6 +22,8 @@ impl<R: Runtime> Wallpaper<R> {
shuffle: true,
lock_screen_only: true,
current_index: 0,
current_id: Some("demo-0".into()),
image_ids: vec!["demo-0".into(), "demo-1".into(), "demo-2".into()],
image_urls: vec![
"/wallpapers/alpine.png".into(),
"/wallpapers/waterfall.png".into(),
@@ -100,6 +102,15 @@ impl<R: Runtime> Wallpaper<R> {
pub fn next_wallpaper(&self) -> crate::Result<WallpaperState> {
let mut state = Self::demo();
state.current_index = 1;
state.current_id = Some("demo-1".into());
Ok(state)
}
pub fn apply_wallpaper(&self, payload: ApplyWallpaperRequest) -> crate::Result<WallpaperState> {
let mut state = Self::demo();
if let Some(index) = state.image_ids.iter().position(|id| id == &payload.id) {
state.current_index = index;
state.current_id = Some(payload.id);
}
Ok(state)
}
pub fn get_immich_connection(&self) -> crate::Result<ImmichConnection> {
+1
View File
@@ -46,6 +46,7 @@ pub fn init<R: Runtime>() -> TauriPlugin<R> {
commands::set_setting,
commands::set_interval,
commands::next_wallpaper,
commands::apply_wallpaper,
commands::get_immich_connection,
commands::connect_immich,
commands::disconnect_immich,
+5
View File
@@ -70,6 +70,11 @@ impl<R: Runtime> Wallpaper<R> {
.run_mobile_plugin("nextWallpaper", ())
.map_err(Into::into)
}
pub fn apply_wallpaper(&self, payload: ApplyWallpaperRequest) -> crate::Result<WallpaperState> {
self.0
.run_mobile_plugin("applyWallpaper", payload)
.map_err(Into::into)
}
pub fn get_immich_connection(&self) -> crate::Result<ImmichConnection> {
self.0.run_mobile_plugin("getImmichConnection", ()).map_err(Into::into)
}
+8
View File
@@ -9,6 +9,8 @@ pub struct WallpaperState {
pub shuffle: bool,
pub lock_screen_only: bool,
pub current_index: usize,
pub current_id: Option<String>,
pub image_ids: Vec<String>,
pub image_urls: Vec<String>,
}
@@ -38,6 +40,12 @@ pub struct DeleteImageRequest {
pub id: String,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct ApplyWallpaperRequest {
pub id: String,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct DeleteImagesRequest {