# krzysztofmarciniak/minimal-window-manager architecture

> Architecture diagram of the GitHub repository krzysztofmarciniak/minimal-window-manager, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/krzysztofmarciniak/minimal-window-manager
- Repository: https://github.com/krzysztofmarciniak/minimal-window-manager

## Overview

##### Project Type and Purpose
- This is a minimal window manager for Linux/X11. Its main aim is to handle a maximum of two windows per desktop without extra frills like borders, gaps, floating windows, or a status bar.
- The README clarifies that keyboard events (e.g., mod keys coupled with specific actions) trigger commands such as launching a terminal (st), launching dmenu, or switching desktops.

##### File Structure
- The entire logic is implemented primarily in main.c.
- Supporting files such as Makefile (for building), audio.sh (possibly for audio feedback or additional command control), and other standard files (.gitignore, LICENSE, README.md) support project management and distribution.

- Main Components:
▪ X Server: The external display server that the window manager communicates with to receive keyboard and window events.
▪ MWM Process (main.c): This is the core component that performs the following:
- Event Loop: Captures and dispatches X events (like key presses or window focus changes).
- Key-binding Handler: Maps key combinations (e.g., Mod+Enter, Mod+p, etc.) to actions such as launching st (the terminal) or dmenu.
- Window Layout Manager: Implements the management and positioning of windows according to the minimal rules (maximum two windows per desktop, no borders or gaps).
- Desktop Manager: Manages switching between desktops (0-9) based on user input.
▪ External Commands/Utilities:
- Terminal (st) and dmenu, which are invoked from within the window manager when needed.
- Audio (audio.sh) if this script plays a role in auditory notifications or sound processing (you might note it as an auxiliary component).

- Relationships & Interactions:
▪ The MWM process connects directly to the X server, receiving input events and sending commands that adjust the window layout.
▪ The key-binding subsystem receives events from the X event loop and invokes external utilities (terminal, dmenu) or changes in window focus/desktop management.

- Architectural Patterns & Design Principles:
▪ Very minimal and tightly integrated design: All logic is contained in a few hundred lines of C code.
▪ The “minimal” philosophy drives the design – only the essentials are included without extra layers between user inputs and responses.

- Relevant Technologies:
▪ C as the implementation language.
▪ X11 (Xlib) for interfacing with the X server.
▪ make for building the project.

## Diagram (Mermaid)

```mermaid
flowchart TD
    X["X Server"]:::external
    M["MWM Process (main.c)"]:::internal
    E["Event Loop"]:::internal
    K["Key Binding Handler"]:::internal
    W["Window Layout Manager"]:::internal
    D["Desktop Manager"]:::internal
    T["st (Terminal)"]:::external
    DM["dmenu"]:::external
    A["audio.sh"]:::external
    MF["Makefile"]:::build

    X -->|"sends_event"| M
    M -->|"initializes"| E
    E -->|"dispatches"| K
    E -->|"manages"| W
    K -->|"launch"| T
    K -->|"invoke"| DM
    K -->|"switch"| D
    K -->|"audio_feedback"| A
    MF -->|"builds"| M

    classDef internal fill:#bbf,stroke:#333,stroke-width:2px;
    classDef external fill:#f9d,stroke:#333,stroke-width:2px;
    classDef build fill:#fdd,stroke:#333,stroke-width:2px;

    click M "https://github.com/krzysztofmarciniak/minimal-window-manager/blob/main/main.c"
    click MF "https://github.com/krzysztofmarciniak/minimal-window-manager/tree/main/Makefile"
    click A "https://github.com/krzysztofmarciniak/minimal-window-manager/blob/main/audio.sh"
```
