How lgug2z/komorebi works
Based on our analysis of the file tree and the detailed README, the project is a Rust-based tiling window manager for Windows called “komorebi”. Its purpose is to extend Windows’ native Desktop Window Manager (DWM) with tiling features and a rich CLI to control window arrangement, workspaces, animations, borders, and more. It is designed to integrate with external tools (like AutoHotKey and whkd) via IPC mechanisms (named pipes, Unix domain sockets, and even TCP) as well as a Rust client library for event subscriptions.
Main Components
• Core Engine ("komorebi"):
– Responsible for the core tiling logic, window management, workspace handling, monitor reconciliation, and integration with Windows APIs.
– Contains submodules like the Animation Manager, Border Manager, Focus Manager, Window Manager, and Workspace Reconciliator.
– Manages configuration (both static and dynamic, via JSON and CLI commands), and interfaces with the operating system (including DWM).
• Command-Line Interface (CLI) and Client Subsystem ("komorebic" and "komorebi-client"):
– Provides the CLI tools for users to control the window manager (e.g., commands like “start”, “stop”, “move-to-workspace”, “toggle-tiling”, etc.).
– Offers a subscription API (through named pipes, Unix domain sockets, and TCP) to relay events and state changes enabling integrations (demonstrated with example code in NodeJS and Rust).
• GUI Component ("komorebi-gui" and "komorebi-bar"):
– Offers a graphical status bar and possibly other UI elements that interact with the core engine.
– The “komorebi-bar” subproject (with its own modules like widget, render, config, etc.) displays information such as CPU, network, battery, and window-related data.
• Themes and Configurations ("komorebi-themes"):
– Contains design assets, theming logic, and configuration schemas (with JSON schemas provided) that allow customization of the window manager’s appearance and behavior.
• Documentation, Build, and Integration Assets:
– Extensive CLI documentation, workflow guides, and examples, which clarify how to integrate with third-party tools and how the IPC channels work.
Relationships and Interactions
• User Interaction Path:
– Users interact with the system via CLI commands (through “komorebic”) or via external GUI/statues (through “komorebi-bar” or “komorebi-gui”).
– These commands and events are passed to the core engine which then makes calls to the Windows API to manage windows and workspaces.
• IPC and Event Subscription:
– The core engine sends events (via window manager events, notifications, and socket messages) over named pipes, Unix domain sockets, or TCP.
– The “komorebi-client” crate and other subscriber tools receive these events and can build additional integrations or user-interface features.
• Modular and Extensible Design:
– Each subsystem (e.g., animations, borders, focus, window positioning) is implemented as a distinct module or sub-crate, facilitating easier maintenance, testing, and potential future refactoring.
Architectural Patterns and Design Principles
• Modular Design: Each major feature is isolated within its own module (e.g., core, animation, border manager, workspace, IPC subscribers) and even separate Cargo packages which encourages separation of concerns and reusability.
• Event-Driven Architecture: Events (such as window focus changes, workspace updates, and configuration reloads) are published and consumed via IPC channels, making the system reactive and extensible.
• Clear Separation Between API Layers: Distinguish between the external interface (CLI, GUI, and client libraries) and the internal core engine which deals with Windows-specific operations.