| 1 | # OXWM Recent Updates |
| 2 | |
| 3 | ## Lua Configuration Support (Latest) |
| 4 | |
| 5 | OXWM now supports **Lua-based configuration** as an alternative to the compiled Rust configuration. This is a major update that makes the window manager much more user-friendly and easier to customize. |
| 6 | |
| 7 | ### Key Features |
| 8 | |
| 9 | #### 1. **Dynamic Configuration - No Compilation Required** |
| 10 | - Edit your config file and reload with `Mod+Shift+R` - changes apply instantly |
| 11 | - No need to recompile the entire window manager for config changes |
| 12 | - Configuration file located at `~/.config/oxwm/config.lua` |
| 13 | |
| 14 | #### 2. **Full Feature Parity** |
| 15 | The Lua configuration supports all features previously available in Rust config: |
| 16 | - Window appearance (borders, gaps, fonts) |
| 17 | - Keybindings (single keys and keychords) |
| 18 | - Layout management and custom symbols |
| 19 | - Status bar configuration |
| 20 | - Workspace tags |
| 21 | - Autostart commands |
| 22 | - Color schemes |
| 23 | |
| 24 | #### 3. **LSP Support & Autocomplete** |
| 25 | Config files include comprehensive type annotations for Lua language servers: |
| 26 | - Full autocomplete for all configuration options |
| 27 | - Type checking to catch errors before runtime |
| 28 | - Hover documentation for all fields |
| 29 | - IntelliSense support in modern editors (VS Code, Neovim, etc.) |
| 30 | |
| 31 | ### Configuration Structure |
| 32 | |
| 33 | ```lua |
| 34 | ---@type Config |
| 35 | config = { |
| 36 | -- Appearance |
| 37 | border_width = 2, |
| 38 | border_focused = 0x6dade3, |
| 39 | border_unfocused = 0xbbbbbb, |
| 40 | font = "monospace:style=Bold:size=10", |
| 41 | |
| 42 | -- Window gaps |
| 43 | gaps_enabled = true, |
| 44 | gap_inner_horizontal = 5, |
| 45 | gap_inner_vertical = 5, |
| 46 | gap_outer_horizontal = 5, |
| 47 | gap_outer_vertical = 5, |
| 48 | |
| 49 | -- Basics |
| 50 | modkey = "Mod4", |
| 51 | terminal = "st", |
| 52 | |
| 53 | -- Workspace tags |
| 54 | tags = {"1", "2", "3", "4", "5", "6", "7", "8", "9"}, |
| 55 | |
| 56 | -- Keybindings (see below for details) |
| 57 | keybindings = { ... }, |
| 58 | |
| 59 | -- Status bar blocks (see below for details) |
| 60 | status_blocks = { ... }, |
| 61 | |
| 62 | -- Color schemes |
| 63 | scheme_normal = { ... }, |
| 64 | scheme_occupied = { ... }, |
| 65 | scheme_selected = { ... }, |
| 66 | |
| 67 | -- Autostart commands |
| 68 | autostart = { |
| 69 | "picom -b", |
| 70 | "nitrogen --restore &", |
| 71 | }, |
| 72 | } |
| 73 | ``` |
| 74 | |
| 75 | ### Keybindings |
| 76 | |
| 77 | #### Single Key Bindings |
| 78 | ```lua |
| 79 | { |
| 80 | modifiers = {"Mod", "Shift"}, |
| 81 | key = "Return", |
| 82 | action = "Spawn", |
| 83 | arg = "alacritty" |
| 84 | } |
| 85 | ``` |
| 86 | |
| 87 | #### Keychords (Multi-key Sequences) |
| 88 | ```lua |
| 89 | { |
| 90 | keys = { |
| 91 | {modifiers = {"Mod4"}, key = "Space"}, |
| 92 | {modifiers = {}, key = "T"} |
| 93 | }, |
| 94 | action = "Spawn", |
| 95 | arg = "st" |
| 96 | } |
| 97 | ``` |
| 98 | |
| 99 | Press Escape to cancel any in-progress keychord. |
| 100 | |
| 101 | #### Available Modifiers |
| 102 | - `"Mod"` - Replaced with your configured modkey |
| 103 | - `"Mod1"` - Alt key |
| 104 | - `"Mod4"` - Super/Windows key |
| 105 | - `"Shift"` - Shift key |
| 106 | - `"Control"` - Control key |
| 107 | - `"Mod2"`, `"Mod3"`, `"Mod5"` - Additional modifiers |
| 108 | |
| 109 | #### Available Actions |
| 110 | - `"Spawn"` - Launch a program (arg: string or string[]) |
| 111 | - `"KillClient"` - Close focused window |
| 112 | - `"FocusStack"` - Focus next/prev in stack (arg: 1 or -1) |
| 113 | - `"FocusDirection"` - Focus by direction (arg: 0=up, 1=down, 2=left, 3=right) |
| 114 | - `"SwapDirection"` - Swap window by direction (arg: 0=up, 1=down, 2=left, 3=right) |
| 115 | - `"Quit"` - Exit window manager |
| 116 | - `"Restart"` - Restart and reload config |
| 117 | - `"Recompile"` - Recompile and restart (for Rust config) |
| 118 | - `"ViewTag"` - Switch to tag (arg: tag index) |
| 119 | - `"MoveToTag"` - Move window to tag (arg: tag index) |
| 120 | - `"ToggleGaps"` - Toggle gaps on/off |
| 121 | - `"ToggleFullScreen"` - Toggle fullscreen mode |
| 122 | - `"ToggleFloating"` - Toggle floating mode |
| 123 | - `"ChangeLayout"` - Switch to specific layout (arg: layout name) |
| 124 | - `"CycleLayout"` - Cycle through layouts |
| 125 | - `"FocusMonitor"` - Focus monitor (arg: 1 or -1) |
| 126 | - `"SmartMoveWin"` - Smart window movement |
| 127 | - `"ExchangeClient"` - Exchange window positions |
| 128 | |
| 129 | ### Status Bar Configuration |
| 130 | |
| 131 | Status blocks support various command types for displaying system information: |
| 132 | |
| 133 | ```lua |
| 134 | status_blocks = { |
| 135 | -- RAM usage |
| 136 | { |
| 137 | format = "Ram: {used}/{total} GB", |
| 138 | command = "Ram", |
| 139 | interval_secs = 5, |
| 140 | color = 0x7aa2f7, |
| 141 | underline = true |
| 142 | }, |
| 143 | |
| 144 | -- Date/Time with custom format |
| 145 | { |
| 146 | format = "{}", |
| 147 | command = "DateTime", |
| 148 | command_arg = "%a, %b %d - %-I:%M %P", |
| 149 | interval_secs = 1, |
| 150 | color = 0x0db9d7, |
| 151 | underline = true |
| 152 | }, |
| 153 | |
| 154 | -- Custom shell command |
| 155 | { |
| 156 | format = "Kernel: {}", |
| 157 | command = "Shell", |
| 158 | command_arg = "uname -r", |
| 159 | interval_secs = 999999999, |
| 160 | color = 0xf7768e, |
| 161 | underline = true |
| 162 | }, |
| 163 | |
| 164 | -- Static text (separator) |
| 165 | { |
| 166 | format = " │ ", |
| 167 | command = "Static", |
| 168 | interval_secs = 999999999, |
| 169 | color = 0xa9b1d6, |
| 170 | underline = false |
| 171 | }, |
| 172 | |
| 173 | -- Battery status |
| 174 | { |
| 175 | format = "{}", |
| 176 | command = "Battery", |
| 177 | interval_secs = 30, |
| 178 | color = 0x9ece6a, |
| 179 | underline = true, |
| 180 | battery_formats = { |
| 181 | charging = "⚡ {}%", |
| 182 | discharging = "🔋 {}%", |
| 183 | full = "✓ {}%" |
| 184 | } |
| 185 | }, |
| 186 | } |
| 187 | ``` |
| 188 | |
| 189 | #### Available Status Block Commands |
| 190 | - `"Ram"` - Shows RAM usage (no command_arg needed) |
| 191 | - `"DateTime"` - Shows date/time with strftime format in command_arg |
| 192 | - `"Shell"` - Runs shell command from command_arg |
| 193 | - `"Static"` - Static text (format field determines what's shown) |
| 194 | - `"Battery"` - Shows battery status (requires battery_formats table) |
| 195 | |
| 196 | ### Layout Symbols |
| 197 | |
| 198 | Customize how layouts appear in the status bar: |
| 199 | |
| 200 | ```lua |
| 201 | layout_symbols = { |
| 202 | {name = "tiling", symbol = "[T]"}, |
| 203 | {name = "normie", symbol = "[F]"}, |
| 204 | } |
| 205 | ``` |
| 206 | |
| 207 | ### Color Schemes |
| 208 | |
| 209 | Define color schemes for tag indicators in the status bar: |
| 210 | |
| 211 | ```lua |
| 212 | scheme_normal = { |
| 213 | foreground = 0xbbbbbb, |
| 214 | background = 0x1a1b26, |
| 215 | underline = 0x444444 |
| 216 | }, |
| 217 | scheme_occupied = { |
| 218 | foreground = 0x0db9d7, |
| 219 | background = 0x1a1b26, |
| 220 | underline = 0x0db9d7 |
| 221 | }, |
| 222 | scheme_selected = { |
| 223 | foreground = 0x0db9d7, |
| 224 | background = 0x1a1b26, |
| 225 | underline = 0xad8ee6 |
| 226 | } |
| 227 | ``` |
| 228 | |
| 229 | ### Autostart Commands |
| 230 | |
| 231 | Commands to run when the window manager starts: |
| 232 | |
| 233 | ```lua |
| 234 | autostart = { |
| 235 | "picom -b", |
| 236 | "nitrogen --restore &", |
| 237 | "dunst &", |
| 238 | } |
| 239 | ``` |
| 240 | |
| 241 | ### Advanced Usage |
| 242 | |
| 243 | You can use Lua's full programming capabilities for dynamic configuration: |
| 244 | |
| 245 | ```lua |
| 246 | -- Generate keybindings programmatically |
| 247 | for i = 1, 9 do |
| 248 | table.insert(config.keybindings, { |
| 249 | modifiers = {"Mod"}, |
| 250 | key = tostring(i), |
| 251 | action = "ViewTag", |
| 252 | arg = i - 1 |
| 253 | }) |
| 254 | end |
| 255 | |
| 256 | -- Create helper functions |
| 257 | local function create_spawn_binding(mods, key, cmd) |
| 258 | return {modifiers = mods, key = key, action = "Spawn", arg = cmd} |
| 259 | end |
| 260 | |
| 261 | table.insert(config.keybindings, |
| 262 | create_spawn_binding({"Mod"}, "Return", terminal)) |
| 263 | ``` |
| 264 | |
| 265 | ### Migration from Rust Config |
| 266 | |
| 267 | For existing users with Rust-based configurations: |
| 268 | 1. Your old Rust config still works - no breaking changes |
| 269 | 2. To migrate to Lua, run OXWM and it will generate `~/.config/oxwm/config.lua` |
| 270 | 3. Customize the generated file to match your preferences |
| 271 | 4. Reload with `Mod+Shift+R` to apply changes |
| 272 | |
| 273 | ### Technical Implementation |
| 274 | |
| 275 | - Configuration parsing via `mlua` (Lua 5.4) |
| 276 | - Full deserialization into Rust types with `serde` |
| 277 | - Hot-reloading on `Restart` action |
| 278 | - Comprehensive error reporting for config issues |
| 279 | - Type-safe validation of all configuration values |
| 280 | |
| 281 | ### Files |
| 282 | |
| 283 | - Template: `templates/config.lua` - Default configuration template |
| 284 | - User config: `~/.config/oxwm/config.lua` - User's configuration file |
| 285 | - Test config: `resources/test-config.lua` - Configuration for Xephyr testing |
| 286 | |
| 287 | --- |
| 288 | |
| 289 | ## Documentation Suggestions |
| 290 | |
| 291 | ### New Pages to Create |
| 292 | |
| 293 | 1. **"Lua Configuration Guide"** - Complete guide to Lua config |
| 294 | - Getting started |
| 295 | - Configuration structure |
| 296 | - Examples for common use cases |
| 297 | - Tips and best practices |
| 298 | |
| 299 | 2. **"Keybindings Reference"** - Detailed keybinding documentation |
| 300 | - How to define single key bindings |
| 301 | - How to create keychords |
| 302 | - List of all available actions with examples |
| 303 | - Modifier key reference |
| 304 | |
| 305 | 3. **"Status Bar Configuration"** - Status bar setup guide |
| 306 | - Available command types |
| 307 | - Format string syntax |
| 308 | - Custom shell commands |
| 309 | - Battery configuration |
| 310 | - Creating custom blocks |
| 311 | |
| 312 | ### Pages to Update |
| 313 | |
| 314 | 1. **Installation/Quickstart** |
| 315 | - Mention Lua configuration as the recommended approach |
| 316 | - Add note that no recompilation needed for config changes |
| 317 | - Update first-run instructions |
| 318 | |
| 319 | 2. **Configuration Page** (if exists) |
| 320 | - Add prominent notice about Lua support |
| 321 | - Deprecation notice for Rust config (if planned) |
| 322 | - Link to new Lua configuration guide |
| 323 | |
| 324 | 3. **Keybindings Page** (if exists) |
| 325 | - Update with Lua syntax |
| 326 | - Add keychord examples |
| 327 | - Update modifier key documentation |
| 328 | |
| 329 | ### Highlights for Documentation |
| 330 | |
| 331 | **Key Selling Points:** |
| 332 | - "Edit and reload instantly - no compilation required" |
| 333 | - "LSP-powered autocomplete for config editing" |
| 334 | - "Full Lua programming support for dynamic configs" |
| 335 | - "Keychord support for complex key combinations" |
| 336 | |
| 337 | **Common Questions to Address:** |
| 338 | - How do I reload my config? (`Mod+Shift+R`) |
| 339 | - Where is my config file? (`~/.config/oxwm/config.lua`) |
| 340 | - Can I still use the Rust config? (Yes, for now) |
| 341 | - How do I see config errors? (Check terminal output when starting OXWM) |
| 342 | |
| 343 | ### Example Snippets for Docs |
| 344 | |
| 345 | #### Quick Config Example |
| 346 | ```lua |
| 347 | -- Minimal working config |
| 348 | config = { |
| 349 | modkey = "Mod4", |
| 350 | terminal = "alacritty", |
| 351 | tags = {"web", "code", "term"}, |
| 352 | border_width = 2, |
| 353 | border_focused = 0x89b4fa, |
| 354 | border_unfocused = 0x45475a, |
| 355 | keybindings = { |
| 356 | {modifiers = {"Mod"}, key = "Return", action = "Spawn", arg = "alacritty"}, |
| 357 | {modifiers = {"Mod"}, key = "Q", action = "KillClient"}, |
| 358 | {modifiers = {"Mod", "Shift"}, key = "Q", action = "Quit"}, |
| 359 | } |
| 360 | } |
| 361 | ``` |
| 362 | |
| 363 | #### Advanced Keychord Example |
| 364 | ```lua |
| 365 | -- Open application menu with Mod+Space, then choose app |
| 366 | keybindings = { |
| 367 | -- Mod+Space, then B -> browser |
| 368 | { |
| 369 | keys = { |
| 370 | {modifiers = {"Mod4"}, key = "Space"}, |
| 371 | {modifiers = {}, key = "B"} |
| 372 | }, |
| 373 | action = "Spawn", |
| 374 | arg = "firefox" |
| 375 | }, |
| 376 | -- Mod+Space, then T -> terminal |
| 377 | { |
| 378 | keys = { |
| 379 | {modifiers = {"Mod4"}, key = "Space"}, |
| 380 | {modifiers = {}, key = "T"} |
| 381 | }, |
| 382 | action = "Spawn", |
| 383 | arg = "alacritty" |
| 384 | }, |
| 385 | } |
| 386 | ``` |
| 387 | |
| 388 | --- |
| 389 | |
| 390 | ## Other Recent Updates |
| 391 | |
| 392 | ### Autostart Support |
| 393 | - Added `autostart` field to configuration |
| 394 | - Commands run when window manager starts |
| 395 | - Useful for launching compositors, wallpaper setters, notification daemons, etc. |
| 396 | |
| 397 | ### Fullscreen Fixes |
| 398 | - Fixed issue where fullscreen windows weren't properly applying geometries |
| 399 | - Border handling corrected for fullscreen mode |
| 400 | |
| 401 | ### Layout Updates |
| 402 | - Improved layout switching behavior |
| 403 | - Better handling of layout symbols in status bar |
| 404 | |
| 405 | --- |
| 406 | |
| 407 | **Last Updated:** 2025-11-07 |