| 1 | #+AUTHOR: Tony |
| 2 | #+STARTUP: overview |
| 3 | |
| 4 | * Table of Contents :toc: |
| 5 | - [[#oxwm][OXWM]] |
| 6 | - [[#installation][Installation]] |
| 7 | - [[#arch-linux][Arch Linux]] |
| 8 | - [[#building-from-source][Building from Source]] |
| 9 | - [[#setting-up-oxwm][Setting up OXWM]] |
| 10 | - [[#configuration][Configuration]] |
| 11 | - [[#contributing][Contributing]] |
| 12 | - [[#key-bindings][Key Bindings]] |
| 13 | - [[#features][Features]] |
| 14 | - [[#testing-with-xephyr][Testing with Xephyr]] |
| 15 | - [[#project-structure][Project Structure]] |
| 16 | - [[#architecture-notes][Architecture Notes]] |
| 17 | - [[#development-roadmap][Development Roadmap]] |
| 18 | - [[#license][License]] |
| 19 | |
| 20 | * OXWM — DWM but Better (and oxidized) |
| 21 | A dynamic window manager written in Rust, inspired by dwm but designed to evolve |
| 22 | on its own. Configuration is done in Rust source code, keeping with the suckless |
| 23 | philosophy of *"edit + recompile."*, but with sane defaults and no arbitrary elitism |
| 24 | enforcing bad variable names and bad file structure topology. |
| 25 | |
| 26 | * Installation |
| 27 | ** Arch Linux |
| 28 | Install dependencies: |
| 29 | #+begin_src sh |
| 30 | sudo pacman -S rust cargo libx11 libxft freetype2 fontconfig pkg-config |
| 31 | #+end_src |
| 32 | |
| 33 | ** Building from Source |
| 34 | #+begin_src sh |
| 35 | git clone https://github.com/tonybanters/oxwm |
| 36 | cd oxwm |
| 37 | cargo build --release |
| 38 | sudo cp target/release/oxwm /usr/local/bin/ |
| 39 | #+end_src |
| 40 | |
| 41 | Or use the justfile: |
| 42 | #+begin_src sh |
| 43 | just install |
| 44 | #+end_src |
| 45 | |
| 46 | ** Setting up OXWM |
| 47 | Add the following to your =~/.xinitrc=: |
| 48 | #+begin_src sh |
| 49 | exec oxwm |
| 50 | #+end_src |
| 51 | |
| 52 | Then start X with: |
| 53 | #+begin_src sh |
| 54 | startx |
| 55 | #+end_src |
| 56 | |
| 57 | * Configuration |
| 58 | OXWM follows the suckless philosophy: configuration is done by editing =src/config.rs= and recompiling. |
| 59 | |
| 60 | On first build, =config.rs= is automatically created from =src/default_config.rs=. Your =config.rs= is gitignored, so you can customize it without worrying about merge conflicts. |
| 61 | |
| 62 | To reset your config to defaults: |
| 63 | #+begin_src sh |
| 64 | just reset-config |
| 65 | #+end_src |
| 66 | |
| 67 | Edit =src/config.rs= to customize: |
| 68 | - Keybindings |
| 69 | - Colors and appearance |
| 70 | - Status bar blocks |
| 71 | - Gaps and borders |
| 72 | - Terminal and applications |
| 73 | |
| 74 | After making changes: |
| 75 | #+begin_src sh |
| 76 | just install |
| 77 | #+end_src |
| 78 | |
| 79 | Then reload OXWM with Alt+Shift+R. |
| 80 | |
| 81 | * Contributing |
| 82 | When contributing to OXWM: |
| 83 | |
| 84 | 1. Never commit your personal =src/config.rs= (it's gitignored) |
| 85 | 2. Only modify =src/default_config.rs= if adding new configuration options |
| 86 | 3. Test your changes with =just test= using Xephyr |
| 87 | 4. Document any new features or keybindings |
| 88 | |
| 89 | * Key Bindings |
| 90 | Default keybindings (customizable in config.rs): |
| 91 | |
| 92 | | Binding | Action | |
| 93 | |-----------------+-------------------------| |
| 94 | | Alt+Return | Spawn terminal | |
| 95 | | Alt+J/K | Cycle focus down/up | |
| 96 | | Alt+Q | Kill focused window | |
| 97 | | Alt+Shift+Q | Quit WM | |
| 98 | | Alt+Shift+R | Hot reload WM | |
| 99 | | Alt+1-9 | View tag 1-9 | |
| 100 | | Alt+Shift+1-9 | Move window to tag 1-9 | |
| 101 | | Alt+S | Screenshot (maim) | |
| 102 | | Alt+D | dmenu launcher | |
| 103 | | Alt+A | Toggle gaps | |
| 104 | | Alt+Shift+F | Toggle fullscreen | |
| 105 | |
| 106 | * Features |
| 107 | - Dynamic tiling layout with master/stack |
| 108 | - Tag-based workspaces (9 tags by default) |
| 109 | - Configurable gaps between windows |
| 110 | - Status bar with modular block system |
| 111 | - Battery, RAM, datetime, shell commands |
| 112 | - Custom colors and update intervals |
| 113 | - Click-to-switch tags |
| 114 | - Window focus cycling |
| 115 | - Hot reload without restarting X |
| 116 | - Persistent window tags across restarts |
| 117 | - Mouse hover to focus |
| 118 | - Border indicators for focused windows |
| 119 | - Fullscreen mode |
| 120 | |
| 121 | * Testing with Xephyr |
| 122 | Test OXWM in a nested X server without affecting your current session: |
| 123 | |
| 124 | #+begin_src sh |
| 125 | just test |
| 126 | #+end_src |
| 127 | |
| 128 | This starts Xephyr on display :1 and launches OXWM inside it. |
| 129 | |
| 130 | Or manually: |
| 131 | #+begin_src sh |
| 132 | Xephyr -screen 1280x800 :1 & |
| 133 | DISPLAY=:1 cargo run |
| 134 | #+end_src |
| 135 | |
| 136 | * Project Structure |
| 137 | #+begin_src sh |
| 138 | src/ |
| 139 | ├── main.rs |
| 140 | │ └── main() |
| 141 | │ └── Creates WindowManager and calls .run() |
| 142 | │ |
| 143 | ├── window_manager.rs [CORE - X11 event handling] |
| 144 | │ ├── struct WindowManager |
| 145 | │ │ ├── connection: RustConnection [X11 connection] |
| 146 | │ │ ├── windows: Vec<Window> [All managed windows] |
| 147 | │ │ ├── focused_window: Option<Window> |
| 148 | │ │ ├── layout: Box<dyn Layout> |
| 149 | │ │ ├── window_tags: HashMap<Window, TagMask> |
| 150 | │ │ ├── selected_tags: TagMask |
| 151 | │ │ └── bar: Bar [Status bar] |
| 152 | │ │ |
| 153 | │ ├── new() [Initialize WM, grab root, restore tags, scan windows] |
| 154 | │ ├── run() [Main event loop with block updates] |
| 155 | │ ├── handle_event() [Route X11 events] |
| 156 | │ │ ├── MapRequest → add window, apply layout, update bar, save tag |
| 157 | │ │ ├── UnmapNotify → remove window, update bar |
| 158 | │ │ ├── DestroyNotify → remove window, update bar |
| 159 | │ │ ├── KeyPress → get action, handle it (includes Restart) |
| 160 | │ │ ├── ButtonPress → handle bar clicks |
| 161 | │ │ └── Expose → redraw bar |
| 162 | │ ├── handle_key_action() [Execute keyboard actions] |
| 163 | │ ├── get_saved_selected_tags() [Restore selected tags from _NET_CURRENT_DESKTOP] |
| 164 | │ ├── save_selected_tags() [Persist selected tags to root window] |
| 165 | │ ├── get_saved_tag() [Restore window tag from _NET_CLIENT_INFO] |
| 166 | │ ├── save_client_tag() [Persist window tag to window property] |
| 167 | │ ├── scan_existing_windows() [Manage windows on startup] |
| 168 | │ ├── remove_window() [Remove from Vec, reapply layout] |
| 169 | │ ├── set_focus() [Focus window, update visuals] |
| 170 | │ ├── cycle_focus() [Move focus to next/prev window] |
| 171 | │ ├── view_tag() [Switch to tag/workspace, update visibility] |
| 172 | │ ├── move_to_tag() [Move window to tag] |
| 173 | │ ├── update_bar() [Calculate occupied tags, redraw bar] |
| 174 | │ ├── update_focus_visuals() [Set border colors] |
| 175 | │ ├── update_window_visibility() [Map/unmap windows based on tags] |
| 176 | │ └── apply_layout() [Position all windows below bar] |
| 177 | │ |
| 178 | ├── config.rs [CONFIGURATION - all settings here] |
| 179 | │ ├── BORDER_WIDTH, BORDER_FOCUSED, BORDER_UNFOCUSED |
| 180 | │ ├── FONT [XFT font string] |
| 181 | │ ├── TAG_COUNT, TAGS [Workspace configuration] |
| 182 | │ ├── TERMINAL, MODKEY |
| 183 | │ ├── ColorScheme [Foreground, background, border colors] |
| 184 | │ ├── SCHEME_NORMAL, SCHEME_OCCUPIED, SCHEME_SELECTED |
| 185 | │ ├── KEYBINDINGS [All keybinds as const array] |
| 186 | │ └── STATUS_BLOCKS [Block configurations with format, command, interval] |
| 187 | │ |
| 188 | ├── bar/ |
| 189 | │ ├── mod.rs [Re-exports: Bar, BlockCommand, BlockConfig] |
| 190 | │ ├── bar.rs |
| 191 | │ │ ├── struct Bar [Status bar window with XFT support] |
| 192 | │ │ ├── new() [Create bar X11 window, load font, init blocks] |
| 193 | │ │ ├── draw() [Render tags + blocks with underlines] |
| 194 | │ │ ├── update_blocks() [Update block content based on intervals] |
| 195 | │ │ ├── handle_click() [Detect which tag was clicked] |
| 196 | │ │ └── invalidate() [Mark bar as needing redraw] |
| 197 | │ ├── font.rs |
| 198 | │ │ ├── struct Font [XFT font wrapper] |
| 199 | │ │ ├── struct FontDraw [XFT drawing context] |
| 200 | │ │ └── draw_text() [Render text with color] |
| 201 | │ └── blocks/ |
| 202 | │ ├── mod.rs [Block trait, BlockConfig, BlockCommand enum] |
| 203 | │ ├── battery.rs [Battery status block] |
| 204 | │ ├── datetime.rs [Date/time formatting block] |
| 205 | │ └── shell.rs [Shell command execution block] |
| 206 | │ |
| 207 | ├── keyboard/ |
| 208 | │ ├── mod.rs [Re-exports] |
| 209 | │ ├── keycodes.rs [Key constants: Q, J, RETURN, etc] |
| 210 | │ └── handlers.rs |
| 211 | │ ├── enum KeyAction [Spawn, KillClient, FocusStack, ViewTag, Restart, etc] |
| 212 | │ ├── enum Arg [None, Int, Str, Array] |
| 213 | │ ├── struct Key [Keybinding definition] |
| 214 | │ ├── setup_keybinds() [Register keys with X11] |
| 215 | │ └── handle_key_press() [Parse KeyPressEvent → KeyAction] |
| 216 | │ |
| 217 | └── layout/ |
| 218 | ├── mod.rs [Layout trait definition] |
| 219 | └── tiling.rs |
| 220 | └── TilingLayout::arrange() [Calculate window positions]c |
| 221 | #+end_src |
| 222 | |
| 223 | * Architecture Notes |
| 224 | ** Tag System |
| 225 | Tags are implemented as bitmasks (TagMask = u32), allowing windows to belong to multiple tags simultaneously. Each window has an associated TagMask stored in a HashMap. Tags persist across WM restarts using X11 properties (_NET_CURRENT_DESKTOP for selected tags, _NET_CLIENT_INFO for per-window tags). |
| 226 | |
| 227 | ** Status Bar |
| 228 | The bar uses a performance-optimized approach with a modular block system: |
| 229 | - Only redraws when invalidated |
| 230 | - Pre-calculates tag widths on creation |
| 231 | - Blocks update independently based on their configured intervals |
| 232 | - Supports custom colors and underline indicators |
| 233 | - Easily extensible - add new block types in src/bar/blocks/ |
| 234 | |
| 235 | ** Layout System |
| 236 | The tiling layout divides the screen into a master area (left half) and stack area (right half). The master window occupies the full height of the master area, while stack windows split the stack area vertically. Gaps are configurable and can be toggled at runtime. |
| 237 | |
| 238 | * Development Roadmap |
| 239 | ** Current Focus |
| 240 | - Multi-monitor support |
| 241 | - Additional layouts (monocle, floating) |
| 242 | - Master area resizing |
| 243 | - Window swapping in layout |
| 244 | |
| 245 | ** Future Enhancements |
| 246 | - Per-window floating behavior |
| 247 | - Per-program rules (auto-tag assignment, floating rules) |
| 248 | - External bar support (polybar, lemonbar) |
| 249 | - Scratchpad functionality |
| 250 | - Window minimize/restore |
| 251 | |
| 252 | * License |
| 253 | [[https://www.gnu.org/licenses/gpl-3.0.en.html][GPL v3]] |