A live wallpaper for cosmic featuring various strange attractors
Files
README.md

aizawa #

A lightweight, animated wallpaper for the COSMIC desktop that renders a stylized simulation of a strange attractor (the Aizawa attractor by default, with eleven others to choose from, or random to pick a different one on each launch).

Aizawa attractor preview

COSMIC's cosmic-bg service handles static images, colors, gradients, and slideshows, but it does not render live animation. aizawa is a small Wayland client that creates a background layer surface on every output and draws the attractor directly with wl_shm. It is intentionally CPU-light: the simulation runs at 30 fps by default, renders internally at 480p, and lets the compositor upscale the soft glow to your display.

Features #

  • Real-time RK4 integration of 12 strange attractors, selectable with --attractor or randomized with --attractor random
  • Additive particle trails with a soft bloom-like glow
  • Four palettes: aurora, ember, mono, and adaptive
  • adaptive reads the active COSMIC theme palette at startup
  • Slow, cinematic camera motion
  • Per-output layer surfaces, including hotplug handling
  • Low internal resolution with wp_viewporter upscaling
  • Headless PNG preview mode for testing without a compositor
  • No GPU, no video files, no frame directories

Requirements #

  • A Wayland compositor that provides zwlr_layer_shell_v1 and wp_viewporter (COSMIC does)
  • Rust 1.86 or newer to build

The client uses the pure-Rust Wayland backend, so no libwayland-dev headers are required at build time.

Build #

cargo build --release

The binary is target/release/aizawa.

Run #

./target/release/aizawa

It will create a background surface on every connected output and keep running until interrupted.

Preview without a compositor #

./target/release/aizawa --preview preview.png

This renders a settled frame to a PNG and exits. Use --preview-size 1920x1080 for a larger preview, or --preview-time 20 to sample a different camera angle.

Install #

./install/install.sh

The script builds the release binary, installs it to ~/.local/bin/aizawa, installs a systemd user unit, and enables and starts it. Only one startup mechanism is used at a time: any autostart entry from a previous install is removed.

To use an XDG autostart entry instead of the systemd service:

./install/install.sh --autostart

This removes the systemd unit and starts aizawa at your next COSMIC login. To start it immediately:

aizawa &

Uninstall #

./install/uninstall.sh

Options #

Option Default Description
--particles <N> 2400 Number of simulated particles
--fps <N> 30 Target frames per second
--render-height <PX> 480 Internal render height; upscaled to the output
--max-pixels <N> 700000 Cap on internal pixels per output
--trail <SECONDS> 0.5 Trail persistence
--speed <FACTOR> 1.0 Simulation speed multiplier
--exposure <FACTOR> 1.15 Glow exposure
--palette <NAME> aurora aurora, ember, mono, or adaptive
--attractor <NAME> aizawa Attractor to simulate, or random for a different one each launch; see Attractors
--seed <N> fixed Random seed, decimal or 0x hex
--preview <PATH> — Render a PNG preview and exit
--preview-size <WxH> 1280x720 Preview resolution
--preview-time <SEC> 0 Simulation time before the preview
-v, --verbose off Enable debug logging

Examples:

# A denser, faster ember variant
aizawa --particles 4000 --speed 1.4 --palette ember

# A quieter, longer-trail mono variant
aizawa --particles 1600 --trail 1.2 --palette mono

# Follow the active COSMIC desktop theme
aizawa --palette adaptive

# A different attractor
aizawa --attractor lorenz

# A different attractor on every launch
aizawa --attractor random

# Lower CPU use
aizawa --fps 20 --render-height 360 --particles 1500

Configuration #

Preferences can be stored in $XDG_CONFIG_HOME/aizawa/config (usually ~/.config/aizawa/config). The file is read at startup, so the systemd service and the autostart entry keep your choices without needing extra arguments. Command-line options override the file.

The format is one key = value per line. Keys are the long option names without the leading --, and _ is accepted in place of -. Blank lines and # comments are ignored.

# ~/.config/aizawa/config
attractor = lorenz
palette = adaptive
particles = 3200

Supported keys: particles, fps, render-height, max-pixels, trail, speed, exposure, palette, attractor, and seed. Preview and logging options are command-line only. An unknown key or invalid value is reported with its file and line number.

Restart the wallpaper after editing the file:

systemctl --user restart aizawa.service

Attractors #

Select a system with --attractor <NAME>. Names are case-insensitive and _ is accepted in place of -. Use --attractor random to pick a different system on each launch.

Name Aliases
aizawa (default) langford
thomas
lorenz
dadras
chen
lorenz83 lorenz-83
rossler
halvorsen
rabinovich-fabrikant rf
three-scroll tsucs, three-scroll-unified
sprott
four-wing fourwing

Each system has its own preset parameters, camera framing, spawn volume, and speed normalization, so they all appear at a similar size and pace. Presets follow the collection at https://www.dynamicmath.xyz/strange-attractors/, except Halvorsen, which uses the chaotic a = 1.4 instead of 1.89 (the latter settles onto a single limit cycle).

Preview any of them without a compositor:

./target/release/aizawa --attractor halvorsen --preview halvorsen.png

Adaptive palette #

--palette adaptive reads the palette that COSMIC is currently using instead of using a built-in gradient. It looks for the theme mode in ~/.config/cosmic/com.system76.CosmicTheme.Mode/v1/is_dark and then loads the matching com.system76.CosmicTheme.Dark or com.system76.CosmicTheme.Light palette (v2, falling back to v1). The UI accent comes from the theme's accent file, and the particle gradient is built from the theme's accent colors.

The palette is resolved when the wallpaper starts. Restart the service after changing your COSMIC theme or color scheme:

systemctl --user restart aizawa.service

If the theme files cannot be read, adaptive falls back to aurora and logs a warning.

COSMIC notes #

cosmic-bg also creates a background layer surface. aizawa creates its surfaces after cosmic-bg starts, so it normally sits on top. If you change the COSMIC background settings and cosmic-bg recreates its surface above the animation, restart the wallpaper:

systemctl --user restart aizawa.service
# or, if running manually: kill and relaunch aizawa

For the cleanest result, set the COSMIC background to a solid dark color. That keeps cosmic-bg cheap and gives the animation a neutral base if it is ever briefly exposed.

The wallpaper is drawn on the background layer and is not shown on the lock screen. That is intentional: the lock screen should not depend on a user service.

Performance #

Defaults are chosen for a low, steady cost:

  • 2400 particles, RK4 with a fixed 4 ms substep
  • 30 fps, frame-callback paced
  • 480p internal render, capped at 700k pixels per output
  • One shared simulation for all outputs
  • Software rendering into a single wl_shm buffer per output

On a typical desktop CPU this is a small fraction of one core. If you want it even lighter, lower --fps, --render-height, or --particles.

How it works #

The default Aizawa attractor is the three-dimensional system

dx/dt = (z - b) x - d y
dy/dt = d x + (z - b) y
dz/dt = c + a z - z³/3 - (x² + y²)(1 + e z) + f z x³

with a = 0.95, b = 0.7, c = 0.6, d = 3.5, e = 0.25, and f = 0.1. Every attractor is simulated the same way: particles are seeded inside the attractor's basin, pre-warmed (six simulated seconds for Aizawa, tuned per system), and integrated with RK4. The other systems are defined in src/attractor.rs.

Each frame, particles are projected through a slowly moving camera and splatted into a linear-light trail buffer with a normalized 5×5 kernel. The buffer is faded by exp(-dt / trail_seconds), which produces motion blur and glow. A precomputed tone-mapping LUT converts the result to 8-bit sRGB, and the buffer is attached to a wl_shm surface. wp_viewporter scales the low-resolution buffer to the output's logical size.

License #

MIT