Skip to content

Latest commit

 

History

History
206 lines (178 loc) · 10 KB

README.md

File metadata and controls

206 lines (178 loc) · 10 KB

modules/screensaver — custom.screensaver

An idle screensaver whose engine is written in Exsecutor, the capability-typed systems language at github:ALH477/exsecutor. The engine is somnium (examples/somnium/ there, design in docs/design/somnium.md there). It has thirteen effects:

name what
titulus the title card: rain flies together into OLIGARCHY, then EXSECVTOR PINXIT ("Exsecutor painted it") and PVNCTIM CECINIT ("Punctim sang it") type in beneath
signum the Exsecutor logo turning in the starfield, drawn by Exsecutor's own 3D engine (examples/signaculum/forma.exsc, unmodified)
fulmen five lightning bolts, white core, cyan sheath, night sky
cruor gore drips gathering in a pool along the bottom edge
pyramis Sierpinski tetrahedron: white beam in, seven-band rainbow out
edictum scrolling 5x7: I HATE WINDOWS / I HATE MAC / I LOVE LINUX / BSD IS OK
pluvia digital rain
stellae warp starfield
cuniculus the demoscene XOR tunnel, in the logo's crimson and navy
abyssus Mandelbrot deep zoom into the Seahorse Valley (f64)
plasma sine plasma
ignis fire
vita Conway's Life coloured by age

The default order lets the rain resolve into the title and the stars lead into the logo.

custom.screensaver = {
  enable = true;
  # somnia = [ "titulus" "signum" ];  # the Oligarchy/Exsecutor pair only
  # period = 45;            # seconds per effect when cycling
  # fps = 20;
  # timeout = 420;          # idle seconds; must be < hypridle's lock (600)
  # pixelated = true;       # nearest-neighbour upscale of the 160x100 frame
  # backend = "c";          # "c" (fast, default) or "reference" (freestanding)
  # cflags = [ "-march=x86-64-v3" "-mtune=znver4" ];  # default on AMD hosts
};

Off by default. Disabled, it adds nothing and never fetches the exsecutor input.

Performance: two builds of one source, and the GPU

  • backend = "c" (default). exsc's C backend, compiled with cflags and a host (examples/somnium/hospes.c) that buffers output to one frame, so each frame is one write(2). It is portable C11: cflags = [ ] runs on any x86-64. The default AVX2-class -march=x86-64-v3 with -mtune=znver4 targets the Framework 16's Ryzen 7040. Contraction is pinned off, so an FMA-capable -march cannot change a float effect's bits.
  • backend = "reference". The freestanding fasmg build: no libc, and a syscall surface audited to read/write/exit_group. It writes one byte per write(2), which is 48,000 system calls a frame, so it is slower. It is the build Exsecutor's purity claims are about.
  • Both builds write the same bytes. The gate holds each one to exsecutor's golden frames and prints each one's frames per second per effect.
  • The GPU's share is presentation. mpv scales the 160x100 frame and presents it with mpv --vo=gpu --gpu-api=opengl, on the 780M iGPU the compositor already renders on (DRI_PRIME is unset, per docs/dgpu-steam-forcing.md, so there is no cross-device copy). Hyprland rules are float,fullscreen,pin,opaque,noblur,nodim,noanim on class oligarchy-screensaver; the gate still does not cover the compositor. Exsecutor cannot yet put a parallel loop on an AMD GPU: its device path runs a whole program as one workitem, a correctness certificate rather than a speed-up. docs/design/somnium.md §6 in the exsecutor repo says exactly which loops are ready to declare quisque when that changes.

How it fits together

hypridle ── timeout ──> systemctl --user start oligarchy-screensaver.service
                          └─ oligarchy-screensaver (script.nix)
                               loop: request (+ 3D model) | somnium ┐
                                                                    ├─ raw rgb24 160x100
                               mpv --demuxer=rawvideo --fs ... - <──┘
hypridle ── on-resume ─> systemctl --user stop  (kills the cgroup: somnium + mpv)
hypridle ── 660 s ─────> dpms off; stop the screensaver
  • The engine has no clock and no entropy. Time is the frame index; randomness is a 32-bit seed in the request. The host picks the seed ($SRANDOM, fresh per effect), so the screen differs night to night, but the same request always renders the same bytes. That is what lets the gate hold the binary to exsecutor's golden files.
  • Why 160x100. Exsecutor's reference runtime writes arbitrary bytes one write(2) per byte, and the 3D effect renders 512x512 per frame. So the frame is small on purpose, and 16:10 like the Framework 16 panel. mpv scales it up, nearest-neighbour by default.
  • mpv is told not to inhibit idle (--stop-screensaver=no). By default mpv holds an idle inhibitor while it plays, hypridle honours inhibitors, and the lock and DPMS-off listeners would never fire. That would be a screensaver that keeps the session unlocked. The gate asserts the flag.
  • It runs under the lock until DPMS-off, and stopping it at the lock was rejected on purpose: that would uncover the desktop for as long as hyprlock takes to raise its surface. Resume stops it either way.
  • The dim rung (300 s, backlit hosts) comes first, so with the default timeout the screensaver plays at the dimmed brightness. Set timeout below 300 if you want it at full brightness first.
  • The producer loop exits when mpv does. somnium dies of SIGPIPE at its next write, and || return 0 ends the loop. Without that, the loop would respawn somnium into a closed pipe as fast as fork allows. The gate would hang on exactly that failure.

Gate

nix build .#screensaver-tests

No KVM, no compositor. It checks four things:

  1. Both builds render all fifteen effect fixtures byte-identical to exsecutor's goldens, and refuse all six bad requests with exit 1 and no output.
  2. The bash request encoder is byte-identical to exsecutor's fixture requests, and the shipped 3D model is the one the goldens were rendered from.
  3. The real pipeline (real argv plus --vo=null) decodes as 160x100 rgb24, and exits when mpv does. It runs twice: across three effects, and on the logo alone, which exercises the model path.
  4. The idle flag is present.

It also reports frames per second per effect for each build, as a measurement rather than an assertion. That is the number to pick fps and backend against.

Not measured by the gate: anything a compositor or GPU does. That covers the window rules, which monitor gets the fullscreen window, mpv's GPU scaling, and hypridle actually firing the listener. Those need a live Hyprland session.

Evidence, stated plainly

This module and the exsecutor side were written in an environment with no nix and no fasmg. What ran there:

  • nixpkgs-fmt --check (1.3.0) on every changed .nix file.
  • The script's bash, rendered from the template by hand:
    • the request encoder matched exsecutor's fixture requests byte for byte;
    • the produce and view loop ran against the exsecutor oracle standing in for somnium and a fake viewer, across rain, the 3D logo (model path) and the zoom. The loop exited, and no process was left behind.
  • On the exsecutor side:
    • the oracle's copy of the 3D engine is byte-identical to that engine's certified 512x512 render;
    • the C host was exercised with a stand-in program: one write(2) per frame, SIGPIPE on close.

Since then, the reference build has been built and run (for the README animations, assets/screensaver-*.gif):

  • nix build github:ALH477/exsecutor/<the rev in flake.lock>#somnium succeeds, producing the freestanding binary and share/somnium/signaculum_mesh.bin.
  • Driven straight over stdin with the 17-byte request this module's script.nix encodes, it renders all thirteen somnia. All 21 of exsecutor's tests/programs/somnium_* fixtures pass against that binary: 15 render expected.out byte-identical (including abyssus's f64 zoom and the signum model path), and 6 malformed requests are refused with exit 1 and zero bytes.

So the engine is no longer [UNTESTED]: it compiles, it runs, and it agrees with the oracle that wrote the goldens.

Operator confirmation (not a gate). The maintainer has since run the module on the real Framework 16 and reports it working: hypridle fires the listener, the viewer takes the screen, and resume stops it. That is a human observation on one machine, recorded because it is the only evidence that exists for the layer the gate explicitly cannot reach — the compositor, the window rules, and hypridle itself. It is not reproducible in CI and does not substitute for one.

.#screensaver-tests has now run, and passes. That is the reproducible measurement this document was waiting for. Both builds -- the freestanding reference and the C backend -- render every effect fixture byte-identical to exsecutor's goldens and refuse every bad request; the bash request encoder matches exsecutor's fixture requests; and the real pipeline through the real mpv reports 160x100 rgb24 and exits when the viewer does, on both the plain and the 3D-model paths.

Its frames-per-second report, on a Framework 16 (Ryzen 7040), 60 frames per effect:

somnium reference c
plasma 40 fps 2857 fps
ignis 40 fps 4285 fps
vita 39 fps 3157 fps
pluvia 40 fps 3750 fps
stellae 40 fps 4285 fps
cuniculus 39 fps 3750 fps
abyssus 23 fps 384 fps
titulus 40 fps 4285 fps
signum 21 fps 147 fps

Two things to read off that. The C backend is roughly two orders of magnitude faster, which is what backend = "c" is the default for. And the reference build still clears the default fps = 20 on every effect -- its worst case, signum at 21 fps, is the 3D engine rendering 512x512 per frame through one write(2) per byte. The freestanding build is a viable screensaver, not only a proof.

What still has not run: anything involving a compositor or a GPU -- see the gate's own list above.