Skip to content
quillfinchPublic

About

A lightweight Windows live-wallpaper engine: 37 procedural Direct2D scenes, desktop pet, single ~700 KB exe

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LivePaper

A live wallpaper engine for Windows, built directly on the framework components that ship with the operating system. One ~700 KB executable, no installer, no runtime, no third-party libraries, and no image assets — the wallpaper art is generated by code.

Measured while animating on the reference machine:

Metric Value
CPU while animating ~0.5% of one core at 30 fps (0.14 ms CPU per frame)
Working set 53–65 MB
Disk footprint ~700 KB (single file, nothing else)
Startup instant (no runtime to load)

Quick start

# Build (needs the MSYS2 UCRT64 toolchain; no CMake, no NuGet, no network)
.\build.ps1

# Run it — the wallpaper starts and a tray icon appears
.\build\LivePaper.exe

# Switch wallpaper
.\build\LivePaper.exe --scene cyberpunk
.\build\LivePaper.exe --next

# Stop it
.\build\LivePaper.exe --quit

New to it? If anything looks wrong, run the diagnostic first — it explains what the engine sees and which condition is holding it back:

.\build\LivePaper.exe --diag
.\build\LivePaper.exe --status

Wallpapers

Thirty-seven procedural scenes are included. They are drawn with gradients, geometry and layered noise — there are no textures, videos or downloaded assets.

Scene Key What it is
Lines & Connections lines A living graph woven around your real desktop icons
Cyberpunk City cyberpunk Neon skyline, animated signage, rain, wet-street reflections
Nature nature Misty ridges, procedural trees, drifting clouds, falling leaves
Beach beach Sunset shoreline, rolling surf with foam, gulls, glitter path
Anime Sakura anime Pastel sky, cherry tree, drifting petals, floating light motes
Aurora aurora Northern lights over a still lake, with reflections and a star field
Nebula nebula Drifting nebula clouds in complementary hues over a dense star field
Alpine Peaks alpine Snow-lit mountain ridges under a moonlit sky with drifting mist
Fireflies fireflies Glowing fireflies wandering through a dark forest edge
Flow Mesh mesh Slowly folding colour fields in an additive gradient mesh
Deep Ocean ocean God rays from the surface, bubble streams, fish silhouettes, marine snow
Digital Rain matrix The classic falling-glyph cascade, green by default
Koi Pond koi Koi gliding between lily pads, trailing expanding ripples
Lava Flow lava Molten crack networks pulsing through dark volcanic rock, with embers
Snowfall snow Layered snow over a moonlit winter treeline, in three parallax layers
Rain on Glass rain Droplets beading and running down a window over blurred city bokeh
Golden Dunes desert Layered dunes, a low sun, wind-blown sand and a shimmering mirage
Thunderstorm storm Forked lightning flickering under a heavy, flash-lit cloud ceiling
Fireworks fireworks Rockets bursting over a dark hill in peonies, rings and willows
Spiral Galaxy galaxy Thousands of stars in differentially rotating arms around a warm core
Crystal Cave crystal Faceted crystals glowing in a dark grotto with light shafts and sparkles
Clockwork gears Brass gears meshing in a dark machine room under a wandering light
Balloons balloons Striped hot-air balloons drifting over hazy morning hills
Lighthouse lighthouse Twin beams sweeping the night sea from a rocky point
Savanna Dusk savanna Banded sun sinking behind acacias and wind-combed grass
Satin Flow silk Translucent silk ribbons undulating through soft drifting light
Black Hole blackhole An accretion disk swirling around a silent event horizon
Kaleidoscope kaleido A turning mandala of mirrored, drifting shapes
Flow Field flow Currents of light advected through an evolving vector field
Plasma Ball plasma Electric filaments dancing inside a glass orb
Bloom bloom Soft generative color blooms drifting in the dark
Strata strata Layered waves of generative color, rolling over each other
Shards shards Faceted generative glass shimmering in slow rotation
Halos halos Concentric rings and rotating arcs around a quiet glow
Hive hive A hex-cell mosaic rippling with waves of color
Weave weave Ribbon braids crossing in slow weaving waves

| Pillars of Creation | pillars | Gas columns rising off a star field, backlit and billowing | | Stellar Nursery | nursery | Protostars igniting inside a dark molecular cloud | | Galactic Edge | edgeon | An edge-on galaxy: blazing core, dust lane, disk glow | | Atomic Model | atom | Electrons orbiting a jittering nucleus across tilted shells |

Every scene is generative now: each one rotates its hue anchors with the seed or the custom color (see Make it yours). The default seed keeps the classic look for every scene.

Lines & Connections

This one is the reason the project exists. It reads the desktop icon layout from the shell and builds the graph around the icons themselves: each icon becomes a node with a soft halo, near neighbours are joined by filaments, and pulses travel between them. It keeps working when icons move, because the layout is re-read periodically.

The icon query is best-effort, because LVM_GETITEMPOSITION does not reliably fill the caller's buffer across processes (on affected Windows builds — LVM_GETITEMCOUNT and LVM_GETITEMSPACING answer fine, the position query silently returns nothing). So the provider tries, in order:

  1. the shell's real icon positions (staged inside Explorer's address space),
  2. a layout cached from the last time (1) succeeded,
  3. a grid derived from the shell's own icon-cell metrics.

--status reports which source is in use.


Make it yours

Generative scenes are built around two controls:

  • Seed - every scene folds the seed into its layout and its palette, so each value is a different wallpaper. Change it from the tray menu (Shuffle this wallpaper), the panel's Shuffle button, or LivePaper --reshuffle.
  • Custom color - every scene derives its hues from one color. Pick it in the panel's COLOR section (hue + saturation sliders, ten presets, a random button), or leave the toggle off to let the seed choose. Scenes keep their internal color relationships, so Koi stays white-bodied with coloured spots - just in your palette.

An AUTO-CYCLE section lets the engine advance to the next wallpaper every 15 / 30 / 60 minutes (off by default), and LivePaper --cycle <min|off> sets it from the command line.

Desktop pet

A small tamagotchi companion floats just above the taskbar - rendered on a fully transparent window, no background. Pick between six species in the panel's COMPANION section (or LivePaper --pet <key>):

Pet Key Personality
Mochi the cat cat ear twitches, slow tail wag
Taro the shiba shiba fast tail wag, tongue out when happy
Lumi the axolotl axolotl pulsing gills, bubbles, permanent smile
Pip the chick chick wing-flap hops, feathers fly when petted
Boo the ghost ghost hovers, rippling skirt, occasional "booo"
Momo the panda panda nibbles bamboo when fed, rolls when played with

Every pet has its own stats, saved separately in pet.ini. Drag it anywhere along the taskbar (it will never sit over the app icons), click to pet it (hearts + XP), click the cookie to feed it, or the ball to play - a ball bounces across the window and its eyes follow it. XP earns levels (sparkle burst on level-up); hunger and happiness decay in real time; pets chatter in little speech bubbles, blink, hop when double-clicked, and follow your cursor with their eyes. Leave one alone long enough and it falls asleep. It hides itself behind fullscreen apps. Toggle it from the tray menu, the panel's Show desktop pet switch, or petEnabled in the config; Pet card background brings the dark card back if you prefer it.

Hiding wallpapers

Not every wallpaper is for everyone: right-click a wallpaper in the panel to hide it (it disappears from the picker and the rotation), and a Show hidden row restores them. LivePaper --hide <key> / --show <key|all> do the same from the command line.


Command line

LivePaper                       Start the engine (tray icon appears)
LivePaper --scene <name>        Switch wallpaper on the running engine
LivePaper --next | --prev       Cycle wallpapers
LivePaper --reshuffle           Re-roll the current wallpaper's layout
LivePaper --pause | --resume    Pause / resume animation
LivePaper --toggle              Toggle pause           (global hotkey: Ctrl+Alt+P)
LivePaper --fps <n|max>         Set the frame-rate cap
LivePaper --quality <low|balanced|high>
LivePaper --reload              Re-attach after an Explorer restart
LivePaper --status              What the engine is doing right now
LivePaper --quit                Stop the engine
LivePaper --list                List wallpapers
LivePaper --pet <key|list>      Choose the desktop pet companion
LivePaper --install             Start with Windows
LivePaper --uninstall           Remove the startup entry

LivePaper --selftest            Render every wallpaper, validate and time it
LivePaper --diag                Explain the engine's environment and frame timing
LivePaper --screencap [file.png]
                                Capture the real desktop at physical resolution
LivePaper --render [scene] [file.png]
                                Render one wallpaper to a PNG (no desktop needed)
LivePaper --verbose             Write a log to %LOCALAPPDATA%\LivePaper\livepaper.log

Global hotkeys: Ctrl+Alt+P pause/resume, Ctrl+Alt+N next wallpaper. Left-click the tray icon for the control panel; right-click for the menu.


Resource behaviour

The point of the project is to be invisible in Task Manager. That is achieved by:

  • A flip-model swap chain with a waitable frame-latency object. The render loop blocks on that handle instead of polling or spinning, so an idle engine consumes essentially no CPU. This one change took the live engine from ~4.5% of a core to ~0.5%.
  • A frame timer set to the frame interval, not 1 ms. A 1 ms timer wakes the loop ~1000 times a second just to be told the frame is not due yet.
  • Automatic pausing. Rendering stops entirely (the wait never happens) when the machine is on battery, the session is locked, or a fullscreen app is in front. Each of these is configurable, and on a laptop the battery pause is the difference between an idle engine and one that never sleeps.
  • Cached static geometry. The icon halos, skyline, ridges, tree canopies and star fields are built once and re-used; per frame only the moving parts are drawn.
  • Bounded per-frame work. Particle counts, rain, edges and pulses all have hard caps derived from the quality setting, and the "Lines" graph rebuilds its neighbour list only when the icon layout actually changes.
  • Optional reduced-resolution rendering. Scenes can render into an offscreen surface at a fraction of the output size and be upscaled; glow-heavy scenes are visually indistinguishable at 0.85x for materially less fill rate.
  • Adaptive quality. If the measured frame cost exceeds the budget for a sustained period, the internal render scale is nudged down (and back up when there is room). It never overrides the user's explicit quality choice, only scales within it.

On a desktop that is plugged in, expect the engine to sit at roughly half a percent of one core with a ~55 MB working set, and to drop to zero CPU the moment it is told to.


Architecture

src/
  main.cpp                entry point (wWinMain)
  core/
    Log.*                 opt-in file/debugger logging
    Config.*              %APPDATA%\LivePaper\config.ini
    Math.h                vectors, colour, hashes, noise, deterministic RNG
    Win32Compat.*         ABI-exact COM mirrors + D3D/D2D helpers + power/session
    WinMsg.*              cross-process message + remote staging buffer
  gfx/
    GfxDevice.*           D3D11 device, flip swap chain, D2D device context
    Scene.*               scene interface + shared drawing primitives
  engine/
    App.*                 engine loop, CLI, diagnostics, autostart
    WallpaperHost.*       Progman/WorkerW discovery and desktop child window
    IconAnchors.*         desktop icon positions with cache and grid fallback
  scenes/                 the thirty-seven wallpapers
  ui/
    Panel.*               control panel (single Direct2D surface, scrollable)
    Pet.*                 desktop pet window above the taskbar
    Tray.*                notification-area icon, generated at runtime
  ipc/
    Ipc.*                 message-only window + commands
res/                      manifest, icon, version info

Rendering

Direct3D 11 device → Direct2D 1.1 device context → flip-model DXGI swap chain (FLIP_DISCARD, FRAME_LATENCY_WAITABLE_OBJECT, 2 buffers). Scenes draw into the back buffer (or an offscreen surface, when reduced-resolution rendering is on), which is then presented. Everything is B8G8R8A8, so Direct2D composites straight onto the swap chain with no copy.

How the wallpaper gets behind the icons

Explorer hosts desktop icons inside a SHELLDLL_DefView window. Behind it sits Progman or a sibling WorkerW. LivePaper creates its own child window under that host, which puts it behind the icons but in front of the wallpaper. Four discovery strategies are tried in turn, so the classic Windows 7–10 layout and the Windows 11 24H2 layout both work. If Explorer restarts, the engine notices the parent window changed and re-attaches itself.

The host window is a child window, so its coordinates are relative to the parent's client area — not to the screen. Passing screen coordinates straight through is the classic way to end up with a wallpaper that covers only part of the display, so the engine measures the host's client area and positions itself at (0,0) within it. A periodic check re-fits the window (and resizes the swap chain) whenever that client area changes, which is what makes it adapt to resolution changes, taskbar auto-hide, monitor hotplug and DPI changes without a restart.

To confirm the fit, ask the engine rather than a screenshot tool:

.\build\LivePaper.exe --status     # reports "covers host exactly: yes/no"
.\build\LivePaper.exe --screencap shot.png

--screencap matters because a capture taken by a DPI-unaware tool (most PowerShell and System.Drawing snippets) is virtualised: it silently returns logical pixels, so a full-screen wallpaper can look like a partial one. --screencap grabs the bits with physical metrics from inside the engine.

One process, one tray icon

The engine owns the wallpaper window, the tray icon, the hotkeys and an invisible message-only window that serves as the control endpoint. There is no second process, no injected DLL and no shell extension. The CLI verbs are the same executable talking to that endpoint, which is why LivePaper.exe --next acts on the running engine and then exits.

Launching the executable again when an engine is already running does not start a second engine: it opens the running engine's control panel and exits with code 10. The tray icon is additionally gated by a session-wide lock, so even if two engines somehow coexisted only one could ever own a notification-area icon. Both the CLI verbs and a plain double-click therefore stay invisible in the tray.


Building

Requirements: MSYS2 with the UCRT64 toolchain (g++ and windres), and Windows 10 or later. Nothing is downloaded; the build links only against libraries that ship with Windows (d2d1, d3d11, dxgi, dwrite, windowscodecs, shell32, ...).

.\build.ps1                 # Release
.\build.ps1 -Config Debug   # -O0 -g
.\build.ps1 -Clean          # rebuild from scratch
.\build.ps1 -Test           # build then run --selftest

The build script stops a running engine before linking (a running process holds its own image open, which otherwise fails the link with an opaque error) and embeds the icon, version info and DPI manifest from res/.

Toolchain notes (MSYS2 + MinGW, worth knowing)

These were found the hard way and are documented in src/core/Win32Compat.h:

  • D2D1_BITMAP_PROPERTIES1 is 32 bytes under MinGW but its bitmapOptions field is at offset 16 rather than the MSVC bitfield layout. It is passed by value, and if bitmapOptions is left zeroed the call fails with E_INVALIDARG. Always set it explicitly — abi::MakeBitmapProps exists for exactly this.
  • MinGW declares CreateLinearGradientBrush/CreateRadialGradientBrush only in their pointer forms, so the two-argument convenience overloads are unavailable; pass the stop collection directly.
  • %s in a wide printf takes a narrow string and stops at the first NUL. Wide arguments need %ls — a bare %s truncates every log line to one character.
  • near and far are Win32 macros; do not name variables after them.
  • Direct2D and Direct3D headers must be included before any C++ standard header is pulled in inside a namespace.

DPI awareness

The manifest declares system DPI awareness. Per-monitor-v2 was evaluated and rejected: switching to PMv2 broke discovery of the shell's icon ListView on some systems, and the wallpaper only ever needs virtual-screen pixel coordinates, which the metrics API already provides.


Configuration

%APPDATA%\LivePaper\config.ini, written when you change a setting:

scene=lines
fps=30
quality=1              ; 0 low, 1 balanced, 2 high
dim=0.000              ; extra darkening, 0..0.6 (applied over the whole frame)
variation=0            ; layout seed, bumped by --reshuffle
pauseFullscreen=1
pauseBattery=1
pauseLocked=1
pauseOccluded=1        ; pause when other windows cover the desktop
spanAll=1              ; one wallpaper across all monitors
startWithWindows=0
petKind=cat            ; desktop pet species: cat, shiba, axolotl, chick, ghost, panda
p0=0.500               ; per-scene parameters, wired to the panel's controls
p1=0.500               ; p1 is the shared animation speed

The control panel (tray → Control panel, or Ctrl+Alt+P) exposes the scene picker, the active scene's four parameter sliders (each labelled by what it does), the frame-rate cap, quality, the pause toggles, and scrolls when the content grows past the screen. Every scene's layout can be re-rolled without switching away: tray → Shuffle this wallpaper, or LivePaper --reshuffle.


Status and known limitations

Working and verified live:

  • wallpaper renders behind the real desktop icons and stays there
  • the wallpaper exactly covers the desktop host at any resolution, verified by --status (covers host exactly: yes) and by --diag, which samples the far corners of the rendered frame so coverage is proven by content, not geometry
  • one process, one tray icon — a second launch opens the panel instead of duplicating
  • all thirty-seven scenes pass --selftest and stay inside the frame budget
  • icon positions are read from the shell and the graph follows them
  • scene switching, shuffle (--reshuffle), pause/resume, tray menu, hotkeys and the control panel with per-scene parameter sliders
  • dim is applied to the composited frame; --status reports it
  • pausing on battery / lock / fullscreen / desktop-covered; re-attaching after an Explorer restart
  • geometry self-heals on resolution / taskbar / monitor / DPI changes

Not done, in rough priority order:

  • Per-monitor wallpapers. spanAll is on by default; the engine renders one surface across the virtual desktop. Independent per-monitor scenes would need one swap chain and scene instance per monitor.
  • Video wallpapers. Media Foundation is the natural fit and needs no new dependency, but only procedural scenes are implemented.
  • Persisting icon positions. The cache is written whenever a real query succeeds; on machines where the query never succeeds, the metric grid is used instead.
  • Code signing. The binary is unsigned, so SmartScreen will warn on first run.

Licence

Provided as-is for personal use. The wallpapers are generated procedurally by this code; no third-party art, fonts or media are bundled.

About

A lightweight Windows live-wallpaper engine: 37 procedural Direct2D scenes, desktop pet, single ~700 KB exe

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages