# man33li/waylandshader-niri architecture

> Architecture diagram of the GitHub repository man33li/waylandshader-niri, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/man33li/waylandshader-niri
- Repository: https://github.com/man33li/waylandshader-niri

## Overview

WaylandShader-niri adds native Slang shader effects and per-output color controls to the niri compositor. A user loads a preset or changes controls through the Qt controller or CLI; both use compositor-owned asynchronous D-Bus state. The runtime loads presets transactionally, shares preset parameters across outputs while maintaining per-output settings and temporal history, and applies effects at final presentation through niri’s GPU/render hooks and native bridge. Source excerpts are partial; runtime and bridge connections reflect the README’s architecture description rather than sampled implementation details.

Main entry points: [`waylandshader/runtime/src/lib.rs`](https://github.com/man33li/waylandshader-niri/blob/main/waylandshader/runtime/src/lib.rs) (Shader manager), [`src/waylandshader/mod.rs`](https://github.com/man33li/waylandshader-niri/blob/main/src/waylandshader/mod.rs) (Monitor render adapters), [`waylandshader/runtime/src/control.rs`](https://github.com/man33li/waylandshader-niri/blob/main/waylandshader/runtime/src/control.rs) (Control service), [`src/backend/mod.rs`](https://github.com/man33li/waylandshader-niri/blob/main/src/backend/mod.rs) (Output presentation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["Control clients"]
  node_controller["Qt controller"]
  node_client_api["Controller D-Bus client"]
  node_cli["Control CLI<br/>[ctl_main.cpp]"]
end

subgraph group_runtime["Shader runtime"]
  node_runtime_control["Control service<br/>[control.rs]"]
  node_runtime_core["Shader manager<br/>[lib.rs]"]
  node_runtime_settings[("Settings and recents<br/>[lib.rs]")]
  node_runtime_ffi["Native bridge adapter<br/>[bridge.rs]"]
end

subgraph group_integration["Compositor integration"]
  node_niri["niri compositor<br/>[niri.rs]"]
  node_adapter["Monitor render adapters<br/>[mod.rs]"]
  node_gpu_adapter["GPU adapter<br/>[gpu.rs]"]
  node_backend["Output presentation<br/>[mod.rs]"]
  node_tty["TTY presentation<br/>[tty.rs]"]
  node_winit["Winit presentation<br/>[winit.rs]"]
end

subgraph group_rendering["GPU rendering"]
  node_native["GL and EGLImage processing<br/>[bridge.cpp]"]
end

node_user(("User"))
node_preset["Slang preset files"]
node_monitor(("Display outputs"))

node_user -->|"controls"| node_controller
node_user -->|"commands"| node_cli
node_controller -->|"calls"| node_client_api
node_client_api -->|"D-Bus requests"| node_runtime_control
node_cli -->|"D-Bus requests"| node_runtime_control
node_runtime_control -->|"dispatches"| node_runtime_core
node_runtime_core -->|"loads preset"| node_preset
node_runtime_core -->|"updates state"| node_runtime_settings
node_runtime_control -->|"reads and writes"| node_runtime_settings
node_runtime_core -->|"passes shader work"| node_runtime_ffi
node_runtime_ffi -->|"FFI calls"| node_native
node_niri -->|"registers rendering"| node_adapter
node_adapter -->|"uses GPU"| node_gpu_adapter
node_adapter -->|"invokes effects"| node_runtime_core
node_backend -->|"selects backend"| node_tty
node_backend -->|"selects backend"| node_winit
node_tty -->|"renders output"| node_adapter
node_winit -->|"renders output"| node_adapter
node_native -->|"processes frames"| node_monitor

click node_controller "https://github.com/man33li/waylandshader-niri/blob/main/waylandshader/client/controller_main.cpp"
click node_client_api "https://github.com/man33li/waylandshader-niri/blob/main/waylandshader/client/controller_client.cpp"
click node_cli "https://github.com/man33li/waylandshader-niri/blob/main/waylandshader/client/ctl_main.cpp"
click node_runtime_control "https://github.com/man33li/waylandshader-niri/blob/main/waylandshader/runtime/src/control.rs"
click node_runtime_core "https://github.com/man33li/waylandshader-niri/blob/main/waylandshader/runtime/src/lib.rs"
click node_runtime_settings "https://github.com/man33li/waylandshader-niri/blob/main/waylandshader/runtime/src/lib.rs"
click node_runtime_ffi "https://github.com/man33li/waylandshader-niri/blob/main/waylandshader/runtime/src/bridge.rs"
click node_niri "https://github.com/man33li/waylandshader-niri/blob/main/src/niri.rs"
click node_adapter "https://github.com/man33li/waylandshader-niri/blob/main/src/waylandshader/mod.rs"
click node_gpu_adapter "https://github.com/man33li/waylandshader-niri/blob/main/src/waylandshader/gpu.rs"
click node_backend "https://github.com/man33li/waylandshader-niri/blob/main/src/backend/mod.rs"
click node_tty "https://github.com/man33li/waylandshader-niri/blob/main/src/backend/tty.rs"
click node_winit "https://github.com/man33li/waylandshader-niri/blob/main/src/backend/winit.rs"
click node_native "https://github.com/man33li/waylandshader-niri/blob/main/waylandshader/bridge.cpp"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_controller,node_client_api,node_cli,node_user toneBlue
class node_runtime_control,node_runtime_core,node_runtime_settings,node_runtime_ffi toneAmber
class node_niri,node_adapter,node_gpu_adapter,node_backend,node_tty,node_winit toneMint
class node_native toneRose
class node_preset,node_monitor toneIndigo
```

## Components

### Control clients

- [Qt controller](https://github.com/man33li/waylandshader-niri/blob/main/waylandshader/client/controller_main.cpp): `waylandshader/client/controller_main.cpp`
- [Controller D-Bus client](https://github.com/man33li/waylandshader-niri/blob/main/waylandshader/client/controller_client.cpp): `waylandshader/client/controller_client.cpp`
- [Control CLI](https://github.com/man33li/waylandshader-niri/blob/main/waylandshader/client/ctl_main.cpp): `waylandshader/client/ctl_main.cpp`

### Shader runtime

- [Control service](https://github.com/man33li/waylandshader-niri/blob/main/waylandshader/runtime/src/control.rs): `waylandshader/runtime/src/control.rs`
- [Shader manager](https://github.com/man33li/waylandshader-niri/blob/main/waylandshader/runtime/src/lib.rs): `waylandshader/runtime/src/lib.rs`
- [Settings and recents](https://github.com/man33li/waylandshader-niri/blob/main/waylandshader/runtime/src/lib.rs): `waylandshader/runtime/src/lib.rs`
- [Native bridge adapter](https://github.com/man33li/waylandshader-niri/blob/main/waylandshader/runtime/src/bridge.rs): `waylandshader/runtime/src/bridge.rs`

### Compositor integration

- [niri compositor](https://github.com/man33li/waylandshader-niri/blob/main/src/niri.rs): `src/niri.rs`
- [Monitor render adapters](https://github.com/man33li/waylandshader-niri/blob/main/src/waylandshader/mod.rs): `src/waylandshader/mod.rs`
- [GPU adapter](https://github.com/man33li/waylandshader-niri/blob/main/src/waylandshader/gpu.rs): `src/waylandshader/gpu.rs`
- [Output presentation](https://github.com/man33li/waylandshader-niri/blob/main/src/backend/mod.rs): `src/backend/mod.rs`
- [TTY presentation](https://github.com/man33li/waylandshader-niri/blob/main/src/backend/tty.rs): `src/backend/tty.rs`
- [Winit presentation](https://github.com/man33li/waylandshader-niri/blob/main/src/backend/winit.rs): `src/backend/winit.rs`

### GPU rendering

- [GL and EGLImage processing](https://github.com/man33li/waylandshader-niri/blob/main/waylandshader/bridge.cpp): `waylandshader/bridge.cpp`

### Other components

- **User**
- **Slang preset files**
- **Display outputs**

## Connections

- User → Qt controller: controls
- User → Control CLI: commands
- Qt controller → Controller D-Bus client: calls
- Controller D-Bus client → Control service: D-Bus requests
- Control CLI → Control service: D-Bus requests
- Control service → Shader manager: dispatches
- Shader manager → Slang preset files: loads preset
- Shader manager → Settings and recents: updates state
- Control service → Settings and recents: reads and writes
- Shader manager → Native bridge adapter: passes shader work
- Native bridge adapter → GL and EGLImage processing: FFI calls
- niri compositor → Monitor render adapters: registers rendering
- Monitor render adapters → GPU adapter: uses GPU
- Monitor render adapters → Shader manager: invokes effects
- Output presentation → TTY presentation: selects backend
- Output presentation → Winit presentation: selects backend
- TTY presentation → Monitor render adapters: renders output
- Winit presentation → Monitor render adapters: renders output
- GL and EGLImage processing → Display outputs: processes frames
