Writeup

Building WallDesk, a native Windows wallpaper manager

How WallDesk turns a Wallhaven thumbnail into a Windows desktop wallpaper using Next.js, Tauri, Rust, and a local download library.

7 min read
View source
WallDeskTauriRustNext.jsTypeScriptWindows

WallDesk is a Windows app for browsing wallpapers from Wallhaven, collecting favorites, and applying images to the desktop. The simplest path through the app starts with a thumbnail and ends with a file Windows can use as wallpaper. In between, the app has to handle pagination, a full-resolution download, progress updates, and a local record that still makes sense when someone moves or deletes the file.

View the GitHub repository · Download for Windows · Watch the video demo

WallDesk on Windows showing the current wallpaper, a Wallhaven search field, and a grid of popular wallpapers.
The WallDesk home screen, from the project's GitHub repository.

How the app is assembled

The interface is built with Next.js 16, React 19, and TypeScript. Next.js exports the UI to out/, which Tauri 2 bundles with the application. The packaged app runs the UI in a Windows WebView. It doesn't need a Next.js server to run on the user's machine. In development, Tauri starts the Next.js server so changes to the UI can be tested without rebuilding an installer.

LayerTechnologyResponsibility
InterfaceNext.js App Router, React, TypeScriptBrowse, search, wallpaper details, collections, downloads, and settings
StylingTailwind CSS 4, shadcn-style components, LucideResponsive cards, filters, menus, skeletons, and settings controls
UI stateZustand and Tauri StoreKeep views in sync and persist settings, favorites, collections, and downloads
Desktop integrationTauri 2, Rust, and the Rust wallpaper crateSave images on disk, report progress, and apply wallpapers on Windows
DistributionGitHub Actions, GitHub Releases, and Tauri UpdaterBuild Windows installers and distribute signed update artifacts

The Next.js config turns on static export. The Tauri config points the native shell at that export and configures bundling and updates.

From a search to a scrollable feed

Wallhaven is the active provider. The home feed and search share the same pagination machinery. Search can add a keyword, category, sort order, color, aspect ratio, and resolution. Minimum resolution and exact resolution are alternative filters. The settings code resolves which mode to use before the API request is built. Public browsing works without a key. When a user supplies a Wallhaven key, the app sends it as an X-API-Key header.

The request layer uses Tauri's HTTP plugin and normalizes provider results into a common wallpaper record. lib/api.ts represents pagination with a cursor per provider. For Wallhaven, it uses the response's current and last page numbers to decide whether there is another page.

Why the feed keeps a generation counter

An intersection observer watches a sentinel at the bottom of the grid to trigger the next page. In-flight requests are guarded to avoid overlapping loads for the same feed. A set of provider-and-ID keys keeps repeated records from appearing twice. If a response contains only duplicates, the hook can try another page within a bounded loop so the feed doesn't stall.

A different problem occurs when someone changes filters before a response comes back. The previous request can still finish after the new search starts. WallDesk increments a generation counter on reset and checks it before accepting the response. This condensed example shows the guard in use_wallpaper_feed.ts.

ts
const requestedGeneration = generationRef.current;const page = await fetchPage(currentFilters, currentCursors);if (requestedGeneration !== generationRef.current) return;// This response still belongs to the filters on screen.commitPage(page);

Imported public Wallhaven collections supply their own page source to the same hook. That lets the collection view reuse scrolling, deduplication, and error handling. In the grid, cards use provider thumbnails and defer loading images farther down the page. The app only needs the full-resolution file for a preview or an action that uses the original.

Applying a wallpaper is a native operation

A click on Apply starts in TypeScript. The UI derives a filename and calls a Rust command through Tauri's IPC bridge. This simplified example shows the arguments passed by the TypeScript wallpaper wrapper.

ts
const path = await invoke<string>("download_and_set_wallpaper", {  url: wallpaper.imageurl,  filename: wallpaperFilename(wallpaper),  mode: fitMode ?? null,});

On the Rust side, wallpaper.rs creates the destination directory, sanitizes the filename, and reads the HTTP response in chunks. It emits progress roughly every 256 KiB and sends a final event when the file is saved. The frontend can show bytes downloaded even if the server didn't provide a total up front.

The download is buffered in memory. Before writing it to disk, the backend checks whether the buffer has a recognizable image format. That catches cases like an HTML error page returned instead of an image. The apply command then passes the saved path to the wallpaper crate, followed by the chosen fit mode. The available modes are center, crop, fit, span, stretch, and tile. The order matters because changing the mode re-applies the current wallpaper.

text
Wallpaper card  -> TypeScript action  -> Tauri IPC  -> Rust download to Pictures/WallDesk  -> Windows wallpaper update  -> Local download record

What stays on the device

The four local stores hold different information. Settings capture preferences and the optional Wallhaven key. Favorites contain wallpaper records. Collections keep references to imported public collections. The downloads ledger records file paths and metadata for images saved or applied through the app.

A saved record and a saved file are different things

Clicking Apply also records the downloaded file in the library. That matters because Windows still needs the on-disk image, and the user should be able to find it without downloading another copy. Conversely, a ledger entry can outlive the file if the image is moved or deleted outside WallDesk. downloads.ts checks those paths and lets the user re-download a missing image.

The local library can preview existing files through Tauri's asset protocol. The online feed is separate. A connectivity check checks reachability when a request fails and lets the feed resume when the connection comes back. Existing downloads remain useful even while the online catalog is unavailable.

Preferences that affect the UI and the desktop

The settings store holds the default fit mode, resolution filter, and toggles for smooth scrolling and image motion. The wallpaper details page can override the default fit mode for a single application. Light, dark, and system themes change the interface, and a separate palette preference picks its colors. The theme code uses local storage for appearance preferences so the initial page can use them before the native stores finish loading.

Startup, packaging, and updates

The native shell registers the wallpaper commands and starts backend initialization. The frontend hydrates its local data and signals readiness. A watchdog can reveal the main window if the usual splash-screen handoff doesn't finish. The Rust entry point coordinates startup and exposes commands for checking and installing updates.

The release workflow builds on a Windows runner when a version tag is pushed or the workflow is started manually. Tauri packages the static UI and the Rust binary into installers. The updater reads its release manifest from GitHub Releases and verifies update artifacts using the public key configured in the desktop app.

Run the desktop app locally

On Windows, the project needs Node.js, Rust with the MSVC toolchain, the Visual Studio C++ build tools, and WebView2. Run the native development command to exercise wallpaper changes, file access, and the updater inside the desktop shell.

bash
git clone https://github.com/999shotoo/walldesk.gitcd walldesknpm installnpm run tauri dev

Use npm run build to generate the static frontend or npm run tauri build to package the desktop app. The project README documents the Windows setup and links to the installer.