Skip to content

About

Native Wayland screensaver for aliasOS

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

aliasos-screensaver

A native Wayland screensaver for aliasOS. It covers every display with an animated reveal of the aliasOS mark, drawn in block characters, and closes the moment you touch a key, the mouse or the screen.

It is built to aliasOS's rule: feel fastest and be fastest. At rest it uses no CPU, it never allocates per frame, and it redraws only the cells that changed. The numbers below come from make benchmark.

How aliasOS starts it

aliasOS runs aliasos-screensaver when the session has been idle for a while; it can also be run by hand. Before it opens anything it:

  1. takes an exclusive lock on $XDG_RUNTIME_DIR/aliasos-screensaver.lock (/tmp if that is unset), so a second copy exits 0 straight away;
  2. unless force is given, asks aliasos-toggle-enabled screensaver-off (or, without that command, checks ~/.local/state/aliasos/toggles/screensaver-off); switched off exits 1;
  3. unless force is given, asks aliasos-shell lock isLocked (2 second limit); a locked session exits 0;
  4. hides the pointer with hyprctl eval, and shows it again on every way out: normal close, signal, error or panic.

It then puts one overlay surface on each display (wlr-layer-shell, namespace org.aliasos.screensaver, exclusive keyboard), including displays plugged in while it runs. Any key press, click, scroll, touch or pointer motion closes it; motion is ignored for the first 250 ms after the first frame, because a surface appearing under the pointer can produce a stray motion event. SIGTERM, SIGINT, SIGHUP and SIGQUIT close it cleanly too.

While an idle lock is on its way, input doesn't close it, so the unlocked desktop never shows before the lock covers it. aliasos-system-lock writes $XDG_RUNTIME_DIR/aliasos-lock-pending.<pid> (/tmp if that is unset), whose first line is the time in epoch milliseconds by which the lock will be up, and removes it once the lock is secure. While any such note's time is still ahead, the screensaver stays up; the lock then stops it.

It draws ~/.config/aliasos/branding/screensaver.txt if that exists and is not empty, otherwise the mark built into the binary. Colours come from the current theme (~/.local/state/aliasos/current/theme/colors.toml) and the font from Ghostty's font-family (through fc-match), falling back to the system monospace font. Block characters and the mark's triangles are drawn as exact shapes, so the mark is seamless at any size and at 1, 1.25, 1.5 and 2x scale (fractional scaling uses wp_fractional_scale_v1 with wp_viewporter).

Options

aliasos-screensaver [force] [options]
Option Meaning
force, --force Start even if switched off or the session is locked
--input PATH Draw this text file instead of the branding mark
--effect NAME Run only this effect (it still loops)
--seed N Seed the random generator, for repeatable runs
--list-effects Print the effect names and exit
--headless No Wayland: run on an in-memory grid
--frames N Headless: simulation steps to run (default 120)
--cols N, --rows N Headless grid size (default 80x24)
--dump Headless: print the final grid
-h, --help Usage
--version Version

Exit codes: 0 on a normal close (also "already running" and "session locked"), 1 when switched off without force, 2 for bad arguments, 1 for any other error, with a one-line message on stderr.

Headless mode prints one line, for example:

$ aliasos-screensaver --headless --effect ripple --seed 1 --frames 300
effect=ripple frames=300 cols=80 rows=24 drawn=234 changed=11222

Effects

Each effect runs at 60 steps per second for 3.3 to 3.6 seconds, ends on the resting mark (accent at the top fading to the foreground colour at the bottom), rests 8 seconds, and hands over to a different random effect.

  • drift: every character starts at a random spot and glides home, easing out, fading from dim to its resting colour.
  • sweep: a three-column accent band crosses the mark; the mark appears behind it and cools to rest.
  • fall: columns drop in from above, left to right, accelerate and bounce once on landing.
  • unscramble: every cell flickers through random block and punctuation glyphs, then locks to its true character with a short accent flash.
  • ripple: a ring grows from the centre; cells light up in a rainbow by distance as it passes, then cool.
  • glow: the mark appears dim, a soft diagonal highlight passes over it twice, then it warms to its resting colours.

How it stays cheap

  • Nothing runs at rest. A timer exists only while an effect animates. During the 8 second rest the process sleeps in the event loop with one wake-up scheduled, for the next effect.
  • Frames only when needed. A display gets a new frame only when the effect changed something since its last frame, its previous frame callback has arrived and one of its two buffers is free. No frame is ever drawn just because time passed.
  • Damage only. Each effect step reports exactly which cells changed. Only those cells are repainted and only their rectangles are sent as damage (merged into at most 32 rectangles). The whole surface is redrawn only on the first frame and on a resize or scale change. Surfaces are declared opaque so the compositor can skip what is underneath.
  • No allocation per frame. Effect state is allocated once when an effect starts; buffers once per size. The benchmark runs a counting allocator and fails if any simulation step or cell repaint allocates: the count is 0 for every effect at every size.
  • Fast start. Glyphs are rasterised on demand from the font file with our own small rasteriser, so loading the font costs a file read.

make benchmark on the development machine (release build; renderer numbers at 3840x2160 with 12x24 px cells, which is a 320x90 grid):

effect         grid  steps   step mean   step p99   changed       state  allocs paint changed    paint full
                                    ns         ns  per step       bytes  steady      ns/frame      ns/frame
drift         80x24    270        3485       6818      90.4        3744       0             -             -
drift        160x48    270        3598       5971     116.1        3744       0             -             -
drift        320x90    270        3548       6120     143.0        3744       0         26840        835510
sweep         80x24    276         855       1947      23.1         936       0             -             -
sweep        160x48    276         804       1569      23.1         936       0             -             -
sweep        320x90    276        1083       3693      23.1         936       0          3900        893279
fall          80x24    273        1502       2980      16.0        1208       0             -             -
fall         160x48    273        1024       2015      25.9        1208       0             -             -
fall         320x90    273        1089       2261      34.6        1208       0          4047        796562
unscramble    80x24    264        1366       2079      31.5        2808       0             -             -
unscramble   160x48    264        1332       2087      31.5        2808       0             -             -
unscramble   320x90    264        1471       2265      31.5        2808       0          6802        839805
ripple        80x24    258         781       1414      43.9        1872       0             -             -
ripple       160x48    258         767       1408      43.9        1872       0             -             -
ripple       320x90    258         847       1534      43.9        1872       0          4841        816028
glow          80x24    270         944       1419      43.4         936       0             -             -
glow         160x48    270         965       1410      43.4         936       0             -             -
glow         320x90    270        1014       1455      43.4         936       0          6796        841831

startup: fc-match 7609 us, font load 504 us, glyph cache warm-up 397 us (1.5x scale)

Reading it: the costliest effect step (drift) takes about 3.5 µs, 0.02% of the 16.7 ms between steps. Repainting one step's changed cells on a 4K display takes 4 to 27 µs; a full 4K redraw, needed only on the first frame or a resize, takes about 0.85 ms. Effect state is under 4 KB. Font loading went from 44 ms with a general-purpose font library to 0.5 ms with on-demand rasterising (JetBrains Mono Nerd Font); fc-match (about 8 ms) runs on a thread while the startup checks run. The same numbers are written to target/bench.json.

The release binary is about 900 KB (913,560 bytes, stripped).

Build and test

make                      # release build
make check                # cargo test + cargo clippy -D warnings
make benchmark            # the table above, plus target/bench.json
make install PREFIX=/usr  # installs $PREFIX/bin/aliasos-screensaver

Needs Rust 1.89 or newer (edition 2024). The tests never open a display: they use headless mode, and the command-line tests run the binary with a scratch PATH, HOME and XDG_RUNTIME_DIR and no WAYLAND_DISPLAY.

Dependencies

Crate Why
smithay-client-toolkit (with calloop) Wayland client plumbing: registry, outputs and hotplug, seats, layer shell, shared-memory buffers and the event loop. Brings wayland-client and wayland-protocols (fractional scale, viewporter) with it. Built without xkbcommon: any key closes, so no keymap is needed.
ttf-parser Reads glyph outlines and metrics straight from the font file, without loading every glyph up front. Rasterising is our own.
signal-hook Turns SIGTERM, SIGINT, SIGHUP and SIGQUIT into bytes on a pipe that the event loop watches, with no unsafe global state.

No argument parser, random number crate, serialiser or benchmark framework.

Licence

MIT. Copyright (c) 2026 Alias Project, Inc. See LICENSE.

About

Native Wayland screensaver for aliasOS

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages