$ show asmvik/yabai
Yabai is a tiling window manager for macOS that automates window layout using binary space partitioning (BSP) and provides keyboard-driven window management. It operates as a background daemon, managing spaces, windows, and displays through a combination of public macOS accessibility APIs and private frameworks (notably SkyLight). The application features an event-driven architecture that reacts to system events (window creation, focus changes, space transitions) and applies user-defined rules to control window behavior. The codebase is structured around several managers (display, space, window, view, process) and a central event loop. A scripting addition (OSAX) is injected into the Dock.app to perform privileged operations via private APIs, communicating with the main yabai process over a Unix socket. Configuration and control are exposed through a command-line interface (yabai) and can be integrated with hotkey daemons like skhd. While the core functionality is well-implemented, the project faces significant maintenance challenges due to its reliance on undocumented private macOS APIs, which require frequent updates to remain compatible with new macOS releases. The codebase includes version-specific workarounds and architecture-specific implementations (for x86_64, arm64, and arm64e) to address these challenges. Despite these complexities, yabai remains a popular and actively maintained tool for macOS window management. Reusable components include low-level utilities such as a generic hash table, memory pool, dynamic string buffer, and logging system, which are decoupled from yabai-specific logic and could be extracted for use in other C projects.
The LLM identified 4 files worth highlighting for reuse:
A generic hash table implementation with customizable hash and comparison functions. It is self-contained, has no yabai-specific dependencies, and demonstrates a reusable pattern for key-value storage in C projects.
A simple memory pool for fast allocation and deallocation of same-sized objects. It minimizes fragmentation and allocation overhead, has zero external dependencies, and can be reused in any C project requiring efficient object allocation.
A dynamic string buffer that automatically grows as needed. It provides a safe and efficient way to build strings, is isolated from yabai-specific logic, and demonstrates a reusable pattern for string manipulation in C.
A lightweight logging system with log levels (error, warn, info, debug). It is thread-safe, has no internal yabai dependencies, and can be easily integrated into other projects as a standalone utility.