Galaxy Shell / docs
Docs / Interface and features

CSS and GLSL effects in Smithay

openspec/specs/css-window-effects/spec.md · Edit on GitHub ↗

On this page

CSS and GLSL effects in Smithay

Purpose

The compositor has an opt-in engine that applies shaders to application thumbnails in the F9 overview, driven by a small CSS package. This spec indexes the limits of the package and of its control channel.

Requirements

Requirement: No package means the earlier path

Without a package the compositor SHALL use exactly the earlier composition path. Full text: section Introduction.

Scenario: No package means the earlier path

  • WHEN no effect package exists
  • THEN the compositor draws as before

Requirement: Scope of the effect

The effect SHALL apply to application thumbnails in the F9 overview, and input and hit testing keep using the original thumbnail rectangle. The web workspace overview does not enable it; chat content, shell, bars, wallpaper, recovery, cursors and interactive windows outside F9 are out of scope. Full text: section Introduction.

Scenario: Scope of the effect

  • WHEN a thumbnail is deformed in F9
  • THEN hit testing still uses the original thumbnail rectangle

Requirement: Package files

The package MUST contain effect.css and, since 2026-11-10, effect.wgsl. An effect.frag is ignored. Full text: section Introduction.

Scenario: Package files

  • WHEN a package has an effect.frag
  • THEN it is not read and not validated

Requirement: Engine limits

The engine SHALL limit files to 32 KiB, parameters to 16, values to -4..4, offscreen dimensions to 320x200 and the cache to 32 windows, and the deformation area stays clipped to the original rectangle. Full text: section Introduction.

Scenario: Engine limits

  • WHEN a file is above 32 KiB
  • THEN it exceeds the engine limit

Requirement: CSS subset grammar

The grammar SHALL accept exactly one .window rule, optionally followed by one .window:overview rule. The overview can only change parameters declared in the base rule, and repeated states and unknown units, selectors, properties, functions, tokens, times or names produce an explicit error. Full text: section CSS subset.

Scenario: CSS subset grammar

  • WHEN the overview rule sets a parameter not declared in the base rule
  • THEN the package is refused with an explicit error

Requirement: Parameter names and transitions

Names MUST match --[a-z][a-z0-9-]*, and --time and --size are reserved. Duration and delay range from 0 to 10 seconds, and the value delivered to the shader is limited to -4..4. Full text: section CSS subset.

Scenario: Parameter names and transitions

  • WHEN a curve goes past the parameter range
  • THEN the value delivered to the shader stays within -4..4

Requirement: Private control channel

The control channel SHALL be a private Unix socket with permission 0600 and peer credentials restricted to the current UID, and the UI and the iframes MUST NOT receive these commands. Full text: section Query, reload and disable.

Scenario: Private control channel

  • WHEN another user connects to the socket
  • THEN peer credentials refuse it

Requirement: Reload keeps the last valid package

Reload SHALL swap the package only after both its CSS and its shader are accepted. A failure keeps the program and the parameters of the last valid package and shows up in the status. Full text: section Query, reload and disable.

Scenario: Reload keeps the last valid package

  • WHEN a reload is sent with an invalid package
  • THEN the last valid package stays and the failure shows in the status

Requirement: Disable restores original drawing

Disabling SHALL remove the shader and the cache and return to the original drawing. Pixels are used for eligible apps only when F9 is open. Full text: section Query, reload and disable.

Scenario: Disable restores original drawing

  • WHEN the effect is disabled
  • THEN the shader and the cache are removed

Status

Doc status: current contract. The effect package is still read as a legacy theme (theme_requests.rs); themes.md is the broader contract. Since 2026-11-11 (steps 7 and 8 of openspec/changes/archive/2026-11-10-gles-removal-plan/design.md) nothing draws or reads effect.frag: the text below about composing into a GLES texture and compiling GLSL is history, and the engine draws only effect.wgsl under the wgpu renderer. Checked 2026-11-11.

Introduction

The compositor has an opt-in engine that applies shaders to application thumbnails in the F9 overview. It composes the application's surface tree into a GLES texture with alpha, then applies the fragment shader. Input and hit testing keep using the original thumbnail rectangle. The web workspace overview does not enable the effect. Chat content, shell, bars, wallpaper, recovery, cursors and interactive windows outside F9 are out of scope. Effects on application windows (open, close, focus, border, rest) are designed as theme slots in window-effect-slots.md.

Current state (2026-11-11): the paragraphs of this doc that say the shader is GLSL, is compiled in the renderer context or draws through GLES describe the engine until step 7 of the GLES removal. Now effect.wgsl is the drawn shader (openspec/specs/themes/spec.md, Optional WGSL pass), the loader ignores effect.frag completely since step 8, and a build without the wgpu renderer has no renderer and does not start. The CSS subset below is unchanged.

Without a package, the compositor uses exactly the earlier composition path. The default package location is ~/.config/agent-native-os/effects/. It must contain effect.css and, since 2026-11-10, effect.wgsl (an effect.frag is ignored: not read and not validated since 2026-11-11, step 8). You can also select the path at process start with AGENT_NATIVE_EFFECTS_DIR. The compositor finds the default folder even if it does not exist yet, so you can create it and load it by hot reload. While F9 is open, the compositor recomposes the thumbnails on every frame to update u_time. This keeps GPU activity continuous in that presentation. Turn the effect off for reduced motion or power saving.

To install the example in the default location:

install -d -m 700 "$HOME/.config/agent-native-os/effects"
install -m 600 native/smithay/effects/elastic/effect.css "$HOME/.config/agent-native-os/effects/effect.css"
install -m 600 native/smithay/effects/elastic/effect.wgsl "$HOME/.config/agent-native-os/effects/effect.wgsl"

effect.wgsl is the file that draws (openspec/specs/themes/spec.md, Optional WGSL pass); the example no longer ships a .frag (deleted at step 8).

The sources are trusted maintenance resources. Arbitrary GLSL is not a sandbox. File size does not guarantee GPU run time and does not recover a blocked driver. The engine limits files to 32 KiB, parameters to 16, values to -4..4, offscreen dimensions to 320x200 and the cache to 32 windows. The deformation area stays clipped to the original rectangle. There is no external mesh, no silhouette expansion, no spring physics and no free drag.

CSS subset

This is not a browser CSS parser. The grammar accepts exactly one .window rule, optionally followed by one .window:overview rule. It accepts /* ... */ comments, declarations with semicolons, unitless custom parameters and the transition shorthand. The overview can only change parameters declared in the base rule. Repeated states and unknown units, selectors, properties, functions, tokens, times or names produce an explicit error.

Example:

.window {
  --elastic: 0;
  transition: --elastic 760ms linear(0 0%, 1.12 58%, 0.97 84%, 1 100%);
}
.window:overview {
  --elastic: 0.72;
}

Each --name becomes the uniform u_name, and hyphens become underscores. Names must match --[a-z][a-z0-9-]*. The names --time and --size are reserved. Transitions support linear, ease, ease-in, ease-out, ease-in-out, cubic-bezier(x1,y1,x2,y2) and linear(value [position%], ...). For linear(), positions must be absent from all stops, or present and strictly ordered in all of them, from 0% to 100%. Duration and delay range from 0 to 10 seconds, with s or ms units. Curves can go past the parameter range, but the value delivered to the shader is limited to -4..4. When a transition is interrupted, the new segment starts from the visual value computed at that moment.

Every fragment shader is a complete GLSL ES 1.00 shader, without #version, and must contain the line //_DEFINES_, uniform sampler2D tex (or support the external variant), uniform float alpha and Smithay's varying vec2 v_coords. Besides the CSS uniforms, the engine provides u_time in seconds since initialization and u_size in pixels of the thumbnail. Preserve the alpha of the texture sample. A shader can generate transparent pixels. The element does not declare opaque regions.

Query, reload and disable

Find the session and the socket of the compositor in use as openspec/specs/project-loading/spec.md and the coordination rules in AGENTS.md describe. The channel is a private Unix socket with permission 0600 and peer credentials restricted to the current UID. The UI and the iframes do not receive these commands.

python3 scripts/smithay-effects.py --socket "$XDG_RUNTIME_DIR/agent-native-smithay-<PID>/control.sock" status
python3 scripts/smithay-effects.py --socket "$XDG_RUNTIME_DIR/agent-native-smithay-<PID>/control.sock" reload
python3 scripts/smithay-effects.py --socket "$XDG_RUNTIME_DIR/agent-native-smithay-<PID>/control.sock" disable

Replace <PID> with the observed directory. Do not assume a fixed socket, VT or session. Reload recompiles the shader in the renderer context and swaps the package only after both CSS and GLSL are accepted. A failure keeps the program and the parameters of the last valid package and shows up in the status. requestedGeneration, appliedGeneration and pending tell a sent request apart from a confirmed application. active means the shader is compiled and available. Pixels are used for eligible apps only when F9 is open. Disabling removes the shader and the cache and returns to the original drawing.

Tests

The unit tests cover parsing, explicit rejection, base/overview cascade, easing, delay, zero duration, interruption and package preservation after an error. History: the test real_egl_offscreen_tree_shader_and_alpha (no longer in the tree) was ignored by default and uses offscreen EGL without creating a compositor, a window, a Wayland session or a client. It composes two layered elements, checks exact identity and alpha for parameter zero, repeats the same time/uniforms and also compares identity with a Transform::Flipped180 source. Then it compares deformed pixels, edits/reloads GLSL with a frozen clock and confirms that a syntactically invalid shader keeps the same last compiled result. To save before/after PPM images outside the repository:

ANOS_EFFECTS_EGL_BASELINE_PPM=/tmp/agent-native-effects-before.ppm ANOS_EFFECTS_EGL_PPM=/tmp/agent-native-effects-after.ppm cargo test --manifest-path native/smithay/Cargo.toml --locked real_egl_offscreen_tree_shader_and_alpha -- --ignored --nocapture

This proof confirms the synthetic offscreen GLES path. It does not measure the physical desktop, performance, GPU timeout or the visual behavior in each application. No session in use needs a restart during the tests. The first compositor process built with this engine can only be used at the next permitted login.