Architecture
This page summarises how Kabuk is built. The full technical design is in docs/ARCHITECTURE.md in the repository.
Principles
- Near-zero cost when idle. No continuously spinning loop. Everything is event-driven; timers are set for the next real change (the clock to the minute boundary, idle dimming to the remaining time).
- Never touch another process. No DLL injection, no global in-context hooks. Only documented Win32/WinRT APIs. This is the basis of both anti-cheat compatibility and stability.
- Never hang because of another process. Windows are moved with
SWP_ASYNCWINDOWPOSand messages are sent withSendMessageTimeout, so a hung window cannot make Kabuk wait. - Always reversible. Everything Kabuk changes in Windows (hidden windows, taskbar, work area, registry) is saved first and written back on exit, or by the watchdog after a crash.
- Platform-independent core. Layout, configuration, search, contrast and translation are pure Rust and can be tested on Linux too. Win32 is only at the edges.
Processes
| Process | Role |
|---|---|
kabuk-watchdog.exe | Starts at sign-in, launches kabuk.exe and checks every 5 seconds that the bar and window manager answer. On an abnormal exit it restores from the state file, then restarts Kabuk (at most 3 times in 60 seconds). Very small. |
kabuk.exe | The bar, window manager, launcher, notifications, on-screen display, idle dimming and IPC server. kabuk msg … is the IPC client and kabuk --restore is the emergency restore. |
kabuk-settings.exe | The settings app. Runs the settings screen inside WebView2, writes kabuk.toml and uses IPC for live information. Runs only while open. |
Only the watchdog runs at startup, and only with your consent.
Repository layout
Kabuk is a Cargo workspace:
| Crate / app | Contents |
|---|---|
crates/kabuk-core | Config schema and loading, state model, IPC message types, event types |
crates/kabuk-layout | Pure layout engine: dwindle, master, floating, monitor/workspace tree |
crates/kabuk-theme | Theme tokens, light/dark, contrast engine |
crates/kabuk-i18n | Fluent-based translation, date/number formats, Turkish case mapping |
crates/kabuk-search | Launcher fuzzy matching and ranking, calculator |
crates/kabuk-wallgen | Create: provider clients, wallpaper format, validation pipeline |
crates/kabuk-win | Safe Win32/WinRT wrappers |
crates/kabuk-ui | Direct2D/DirectWrite/DirectComposition rendering, node tree, layout, animation, icons, fonts |
apps/kabuk | Main application |
apps/kabuk-watchdog | The watchdog |
apps/kabuk-settings | WebView2 shell and the settings UI |
apps/kabuk-testapp | Test app that mimics problematic window behaviour |
kabuk-layout, kabuk-theme, kabuk-i18n, kabuk-search and kabuk-core have no Windows dependencies.
Threads
- UI thread: message loop and rendering for all Kabuk windows (bar, launcher, notifications, OSD, dimming overlay).
- Window manager thread: receives out-of-context WinEvent callbacks, holds the window state model and computes and applies layouts.
- Input thread: low-level mouse (and if needed keyboard) hooks. It never waits on anything; hooks are removed in game mode.
- Background pool: launcher indexing, stats sampling, file watching.
Shared state moves by messages, not locks.
Key components
- Bar. One window per monitor that does not steal focus, reserving space as a Windows AppBar. The taskbar is hidden and its previous state is backed up; it is hidden again if Explorer shows it or restarts. Modules redraw only when they change.
- Rendering. Direct3D 11, Direct2D and DirectComposition, with text through DirectWrite and fonts loaded in memory (not installed system-wide). No heavy GUI framework.
- Animation. Kabuk's own surfaces animate on the compositor. Application windows are animated with live DWM thumbnails while the real windows are placed in one go. The setting is Full, Reduced or Off.
- Window manager. Decides which windows are manageable, corrects for invisible borders so gaps are even, floats windows that do not fit, and hides windows of inactive workspaces after writing them to the state file. The layout engine is a pure function with property tests: no overlaps, no overflow, equal gaps.
- System tray. Kabuk creates its own tray window, receives icon registrations and forwards every message to Explorer's real tray.
- Game mode and idle dimming. Full-screen detection is event-driven. Idle dimming uses a single timer and a click-through overlay, and is skipped while media is playing or a full-screen app is present.
- Wallpapers. Static wallpapers use the documented
IDesktopWallpaperinterface. Animated wallpapers draw behind the desktop icons, are capped at 30 fps and pause while they cannot be seen. - Configuration, translation and IPC. One versioned TOML file, watched and reloaded live. Translations use Fluent (
locales/tr.ftl,locales/en.ftl). The IPC is a per-user named pipe with one JSON message per line;kabuk msgexit codes are 0 done, 2 bad command, 15 no shell running, 16 refused. - Logs go to
%LOCALAPPDATA%\kabuk\logs\, rotated daily and kept for 7 days.
Compatibility testing
A list of commonly used applications (Discord, Spotify, Steam, Visual Studio, Rider, VS Code, Windows Terminal, Edge, Chrome, Word, Excel, Outlook, Task Manager, Settings, File Explorer, OBS) is tried by hand with the real window manager: tiling, workspaces, dialogs, minimise/maximise, and close/restore. Results are recorded in docs/compat.md; the table has not been filled in yet.