a window manager for x11
- 63 commits
- 1 branch
- 0 tags
| src | 2025-10-06 | |
| .envrc | 2025-09-24 | |
| .gitignore | 2025-09-24 | |
| Cargo.lock | 2025-10-04 | |
| Cargo.toml | 2025-10-04 | |
| flake.lock | 2025-09-19 | |
| flake.nix | 2025-10-03 | |
| justfile | 2025-10-03 | |
| LICENSE | 2025-10-03 | |
| readme.org | 2025-10-05 |
readme.org
Table of Contents
- OXWM — DWM but Better (and oxidized)
- Project Structure
- Event Flow
- Key Bindings
- ⚙ Installation — Running with Nix Flakes
- Testing Xephyr with Justfile
- Current Status
- OXWM Development Todo
- Architecture Notes
- License
OXWM — DWM but Better (and oxidized)
A dynamic window manager written in Rust, inspired by dwm but designed to evolve on its own. Configuration is done in Rust source code, keeping with the suckless philosophy of "edit + recompile."
Project Structure
src/
��������� main.rs
��� ��������� main()
��� ��������� Creates WindowManager and calls .run()
���
��������� window_manager.rs [CORE - X11 event handling]
��� ��������� struct WindowManager
��� ��� ��������� connection: RustConnection [X11 connection]
��� ��� ��������� windows: Vec<Window> [All managed windows]
��� ��� ��������� focused_window: Option<Window>
��� ��� ��������� layout: Box<dyn Layout>
��� ��� ��������� window_tags: HashMap<Window, TagMask>
��� ��� ��������� selected_tags: TagMask
��� ��� ��������� bar: Bar [Status bar]
��� ���
��� ��������� new() [Initialize WM, grab root, restore tags, scan windows]
��� ��������� run() [Main event loop with block updates]
��� ��������� handle_event() [Route X11 events]
��� ��� ��������� MapRequest ��� add window, apply layout, update bar, save tag
��� ��� ��������� UnmapNotify ��� remove window, update bar
��� ��� ��������� DestroyNotify ��� remove window, update bar
��� ��� ��������� KeyPress ��� get action, handle it (includes Restart)
��� ��� ��������� ButtonPress ��� handle bar clicks
��� ��� ��������� Expose ��� redraw bar
��� ��������� handle_key_action() [Execute keyboard actions]
��� ��������� get_saved_selected_tags() [Restore selected tags from _NET_CURRENT_DESKTOP]
��� ��������� save_selected_tags() [Persist selected tags to root window]
��� ��������� get_saved_tag() [Restore window tag from _NET_CLIENT_INFO]
��� ��������� save_client_tag() [Persist window tag to window property]
��� ��������� scan_existing_windows() [Manage windows on startup]
��� ��������� remove_window() [Remove from Vec, reapply layout]
��� ��������� set_focus() [Focus window, update visuals]
��� ��������� cycle_focus() [Move focus to next/prev window]
��� ��������� view_tag() [Switch to tag/workspace, update visibility]
��� ��������� move_to_tag() [Move window to tag]
��� ��������� update_bar() [Calculate occupied tags, redraw bar]
��� ��������� update_focus_visuals() [Set border colors]
��� ��������� update_window_visibility() [Map/unmap windows based on tags]
��� ��������� apply_layout() [Position all windows below bar]
���
��������� config.rs [CONFIGURATION - all settings here]
��� ��������� BORDER_WIDTH, BORDER_FOCUSED, BORDER_UNFOCUSED
��� ��������� FONT [XFT font string]
��� ��������� TAG_COUNT, TAGS [Workspace configuration]
��� ��������� TERMINAL, MODKEY
��� ��������� ColorScheme [Foreground, background, border colors]
��� ��������� SCHEME_NORMAL, SCHEME_OCCUPIED, SCHEME_SELECTED
��� ��������� KEYBINDINGS [All keybinds as const array]
��� ��������� STATUS_BLOCKS [Block configurations with format, command, interval]
���
��������� bar/
��� ��������� mod.rs [Re-exports: Bar, BlockCommand, BlockConfig]
��� ��������� bar.rs
��� ��� ��������� struct Bar [Status bar window with XFT support]
��� ��� ��������� new() [Create bar X11 window, load font, init blocks]
��� ��� ��������� draw() [Render tags + blocks with underlines]
��� ��� ��������� update_blocks() [Update block content based on intervals]
��� ��� ��������� handle_click() [Detect which tag was clicked]
��� ��� ��������� invalidate() [Mark bar as needing redraw]
��� ��������� font.rs
��� ��� ��������� struct Font [XFT font wrapper]
��� ��� ��������� struct FontDraw [XFT drawing context]
��� ��� ��������� draw_text() [Render text with color]
��� ��������� blocks/
��� ��������� mod.rs [Block trait, BlockConfig, BlockCommand enum]
��� ��������� battery.rs [Battery status block]
��� ��������� datetime.rs [Date/time formatting block]
��� ��������� shell.rs [Shell command execution block]
���
��������� keyboard/
��� ��������� mod.rs [Re-exports]
��� ��������� keycodes.rs [Key constants: Q, J, RETURN, etc]
��� ��������� handlers.rs
��� ��������� enum KeyAction [Spawn, KillClient, FocusStack, ViewTag, Restart, etc]
��� ��������� enum Arg [None, Int, Str, Array]
��� ��������� struct Key [Keybinding definition]
��� ��������� setup_keybinds() [Register keys with X11]
��� ��������� handle_key_press() [Parse KeyPressEvent ��� KeyAction]
���
��������� layout/
��������� mod.rs [Layout trait definition]
��������� tiling.rs
��������� TilingLayout::arrange() [Calculate window positions]
Event Flow
- X11 event arrives → run() receives it
- handle_event() matches event type
- For KeyPress:
- keyboard::handle_key_press() → KeyAction
- handle_key_action() executes action
- update_bar() if tags/windows changed
- For Map/Unmap:
- Modify windows Vec and window_tags HashMap
- apply_layout() repositions everything (accounting for bar)
- update_bar() shows occupied tags
- update_focus_visuals() redraws borders
- For ButtonPress on bar:
- bar.handle_click() determines clicked tag
- view_tag() switches workspace
Key Bindings
| Binding | Action |
|---|---|
| Alt+Return | Spawn terminal |
| Alt+J/K | Cycle focus down/up |
| Alt+Q | Kill focused window |
| Alt+Shift+Q | Quit WM |
| Alt+Shift+R | Hot reload WM |
| Alt+1-9 | View tag 1-9 |
| Alt+Shift+1-9 | Move window to tag 1-9 |
| Alt+S | Screenshot (maim) |
| Alt+D | Application launcher |
⚙ Installation — Running with Nix Flakes
You can set up a reproducible development environment with Rust, Cargo, Xephyr, xterm, and just by using the flake.
git clone https://github.com/tonybanters/oxwm
cd oxwm
# enter the dev shell
nix develop
# build normally
cargo build
Testing Xephyr with Justfile
The justfile includes a test recipe that starts Xephyr on :1, launches
test clients (xterm, xclock), and runs oxwm in the foreground.
# inside nix develop
just test
This should open a new Xephyr window. oxwm will attach to it and log X11 events in your host terminal. Clients like xterm/xclock will appear inside Xephyr.
Current Status
Working Features
- ✓ X11 event handling and window management
- ✓ Tag system (9 workspaces) with keyboard switching
- ✓ Window focus cycling (Alt+J/K)
- ✓ Tiling layout with border indicators
- ✓ Status bar showing tags
- Visual indicators: selected (white), occupied (gray line), empty (dim)
- Click-to-switch tags
- Performance-optimized redrawing
- ✓ Basic keybindings (spawn, kill, focus, tags)
- ✓ Configuration via Rust constants in config.rs
- ✓ Hot reload functionality (Alt+Shift+R)
- ✓ Persistent window tags across restarts
- ✓ Status bar blocks system
- DateTime, Battery, Shell command blocks
- Configurable colors and update intervals
- Underline indicators for blocks
- Proper spacing between blocks
- Hackable block system for custom widgets
- ✓ dmenu integration (Alt+D)
Immediate Next Steps
- ☐ Mouse hover to focus windows
- ☐ Configurable gaps between windows (vanitygaps-style)
- ☐ Decide on reload behavior (should it auto-rebuild?)
Long Term Roadmap
- ☐ Multi-monitor support
- ☐ Additional layouts (monocle, floating, etc.)
- ☐ Per-window floating behavior
- ☐ Per-program rules (auto-tag assignment, floating rules)
- ☐ Master area resizing
- ☐ Window swapping in layout
- ☐ External bar support (polybar, lemonbar, etc.)
OXWM Development Todo
DONE Core Window Management [2/2]
- ☑ Fix layout after program is closed (handle UnmapNotify events)
- ☑ Add UnmapNotify to event handling
- ☑ Remove closed windows from windows vector
- ☑ Re-apply layout after window removal
- ☑ Add keybind to swap focus between windows
- ☑ Track focused window in WindowManager struct
- ☑ Implement focus cycling logic
- ☑ Add visual focus indication (borders/colors)
DONE Tag System [3/3]
- ☑ Implement tag/workspace system (9 tags)
- ☑ Keybinds to switch tags (Alt+1-9)
- ☑ Keybinds to move windows to tags (Alt+Shift+1-9)
DONE Status Bar [2/2]
- ☑ Create basic bar window at screen top
- ☑ Display tag indicators with state (selected/occupied/empty)
DONE Bar Enhancements [3/3]
- ☑ Add status text area (right side of bar)
- ☑ Implement clock widget
- ☑ Add system information widgets
DONE Key System Improvements [2/2]
- ☑ dmenu integration for application launching
- ☑ More spawn commands in config (screenshot, volume, etc.)
TODO Layout System [0/5]
- ☐ Mouse hover to focus windows
- ☐ Configurable gaps between windows (vanitygaps-style)
- ☐ Add monocle layout
- ☐ Add floating layout mode
- ☐ Handle window resize requests properly
TODO Advanced Features [0/4]
- ☐ Decide on reload behavior (auto-rebuild vs manual)
- ☐ Multi-monitor support
- ☐ Per-window rules (floating, tag assignment)
- ☐ Master area resizing keybinds
Polish & Features
- ☐ Clean window destruction/cleanup
- ☐ Handle edge cases (empty window list, invalid windows)
- ☐ Better error messages and logging
- ☐ Proper font rendering in bar (currently using basic X11 text)
Architecture Notes
Tag System
Tags are implemented as bitmasks (TagMask = u32), allowing windows to belong to multiple tags simultaneously (though current UI only supports single tags). Each window has an associated TagMask in window_tags HashMap. Tags persist across WM restarts using X11 properties (_NET_CURRENT_DESKTOP for selected tags, _NET_CLIENT_INFO for per-window tags).
Bar Design
The bar uses a performance-optimized approach with a modular block system:
- Only redraws when invalidate() is called
- Pre-calculates tag widths on creation
- Uses X11 graphics context for efficient drawing
- Click handling uses O(n) tag width lookup
- Blocks are updated independently based on their interval
- Each block can have custom colors and optional underline indicators
- Blocks are defined in config.rs and can be:
- DateTime: Display formatted date/time
- Battery: Show battery status with custom formats
- Shell: Execute shell commands and display output
- Static: Display fixed text
- Blocks are easily hackable - add new block types in src/bar/blocks/
Configuration Philosophy
Following dwm's approach: all configuration is in Rust source code. No runtime config files. Edit config.rs and recompile. This ensures type safety and compile-time validation of all settings.