tony / oxwm

Branch: 5342e9d
Switch branches/tags
master
tonybanters Added documentation for bsd, and fixed readme in general. d7c5cd2 2026-03-07
359 lines · 12.8 KB Rendered Raw Blame History
1 #+AUTHOR: Tony
2 #+STARTUP: overview
3
4 [[file:./images/oxwm1.png]]
5
6 * OXWM — DWM but Better
7 A dynamic window manager written in Zig, inspired by dwm but designed to evolve beyond it. OXWM features a clean, functional Lua API for configuration with hot-reloading support, ditching the suckless philosophy of *"edit + recompile"*. Instead, we focus on lowering friction for users with sane defaults, LSP-powered autocomplete, and instant configuration changes without restarting your X session.
8
9 *Documentation:* [[https://ox-docs.vercel.app/][ox-docs.vercel.app]]
10
11 * Installation
12 ** NixOS (nixpkgs)
13 Add Oxwm to your =configuration.nix= like so:
14
15 #+begin_src nix
16 { config, pkgs, ... }:
17
18 {
19 services.xserver.windowManager.oxwm.enable = true;
20 }
21 #+end_src
22
23 *** Initialize your config
24 After rebuilding your system with =sudo nixos-rebuild switch=, log in via your display manager.
25
26 On first launch, your initial config file will be automatically created and placed in =~/.config/oxwm/config.lua=. Edit it and reload with =Mod+Shift+R=.
27
28 *** Development setup with Nix
29 For development, use the provided dev shell:
30
31 #+begin_src sh
32 # Clone the repository
33 git clone https://github.com/tonybanters/oxwm
34 cd oxwm
35
36 # Enter the development environment
37 nix develop
38
39 # Build and test
40 zig build -Doptimize=ReleaseSmall
41 #+end_src
42
43 ** Arch Linux
44
45 AUR: [[https://aur.archlinux.org/packages/oxwm-git][AUR URL]]
46 #+begin_src
47 yay -S oxwm-git
48 #+end_src
49 This will automatically put a desktop session file into your xsessions directory.
50
51 Manually:
52 Install dependencies:
53 #+begin_src sh
54 sudo pacman -S zig libx11 libxft freetype2 fontconfig libxinerama
55 #+end_src
56 See Build from source
57
58 ** Building from Source
59 Note, on many BSD systems, the zig compiler will agressively attempt to remove debug symbols which is causing a known linker issue. Please use this method on BSD:
60
61 #+begin_src sh
62 git clone https://github.com/tonybanters/oxwm
63 cd oxwm
64 zig build
65 #+end_src
66
67 On other legacy distros, just use:
68
69 #+begin_src sh
70 git clone https://github.com/tonybanters/oxwm
71 cd oxwm
72 zig build -Doptimize=ReleaseSmall --prefix /usr
73 #+end_src
74
75
76
77 ** Setting up OXWM
78 *** Without a display manager (startx)
79 Add the following to your =~/.xinitrc=:
80 #+begin_src sh
81 exec oxwm
82 #+end_src
83
84 Then start X with:
85 #+begin_src sh
86 startx
87 #+end_src
88
89 *** With a display manager
90 If using a display manager (LightDM, GDM, SDDM), OXWM should appear in the session list after installation.
91
92 * Configuration
93 OXWM uses a clean, functional Lua API for configuration. On first run, a default config is automatically created at =~/.config/oxwm/config.lua=.
94
95 ** Quick Example
96 Here's what the new functional API looks like:
97
98 #+begin_src lua
99 -- Set basic options
100 oxwm.set_terminal("st")
101 oxwm.set_modkey("Mod4")
102 oxwm.set_tags({ "1", "2", "3", "4", "5", "6", "7", "8", "9" })
103
104 -- Configure borders
105 oxwm.border.set_width(2)
106 oxwm.border.set_focused_color("#6dade3")
107 oxwm.border.set_unfocused_color("#bbbbbb")
108
109 -- Configure gaps
110 oxwm.gaps.set_enabled(true)
111 oxwm.gaps.set_inner(5, 5) -- horizontal, vertical
112 oxwm.gaps.set_outer(5, 5)
113
114 -- Set up keybindings
115 oxwm.key.bind({ "Mod4" }, "Return", oxwm.spawn("st"))
116 oxwm.key.bind({ "Mod4" }, "Q", oxwm.client.kill())
117 oxwm.key.bind({ "Mod4", "Shift" }, "Q", oxwm.quit())
118
119 -- Add status bar blocks
120 oxwm.bar.set_blocks({
121 oxwm.bar.block.datetime({
122 format = "{}",
123 date_format = "%H:%M",
124 interval = 60,
125 color = "#0db9d7",
126 underline = true,
127 }),
128 oxwm.bar.block.ram({
129 format = "RAM: {used}/{total} GB",
130 interval = 5,
131 color = "#7aa2f7",
132 underline = true,
133 }),
134 })
135 #+end_src
136
137 ** Key Configuration Areas
138 Edit =~/.config/oxwm/config.lua= to customize:
139 - Basic settings (terminal, modkey, tags)
140 - Borders and colors
141 - Window gaps
142 - Status bar (font, blocks, color schemes)
143 - Keybindings and keychords
144 - Layout symbols
145 - Autostart commands
146
147 After making changes, reload OXWM with =Mod+Shift+R=
148
149 ** Creating Your Config
150 Generate the default config:
151 #+begin_src sh
152 oxwm --init
153 #+end_src
154
155 Or just start OXWM - it will create one automatically on first run.
156
157 * Contributing
158 When contributing to OXWM:
159
160 1. Never commit your personal =~/.config/oxwm/config.lua=
161 2. Only modify =templates/config.lua= if adding new configuration options
162 3. Test your changes with =zig build xephyr= using Xephyr or =zig build xwayland= using Xwayland
163 4. Document any new features or keybindings
164
165 * Key Bindings
166 Default keybindings (fully customizable in =~/.config/oxwm/config.lua=):
167
168 | Binding | Action |
169 |------------------------+-----------------------------------|
170 | Super+Return | Spawn terminal |
171 | Super+J/K | Cycle focus through stack |
172 | Super+Q | Kill focused window |
173 | Super+Shift+Q | Quit WM |
174 | Super+Shift+R | Hot reload WM |
175 | Super+1-9 | View tag 1-9 |
176 | Super+Shift+1-9 | Move window to tag 1-9 |
177 | Super+Ctrl+1-9 | Toggle tag view (multi-tag) |
178 | Super+Ctrl+Shift+1-9 | Toggle window tag (sticky) |
179 | Super+S | Screenshot (maim) |
180 | Super+D | dmenu launcher |
181 | Super+A | Toggle gaps |
182 | Super+Shift+F | Toggle fullscreen |
183 | Super+Shift+Space | Toggle floating |
184 | Super+F | Set normie (floating) layout |
185 | Super+C | Set tiling layout |
186 | Super+N | Cycle layouts |
187 | Super+Comma/Period | Focus prev/next monitor |
188 | Super+Shift+Comma/. | Send window to prev/next monitor |
189 | Super+[/] | Decrease/increase master area |
190 | Super+I/P | Inc/dec number of master windows |
191 | Super+Shift+/ | Show keybinds overlay |
192 | Super+Button1 (drag) | Move window (floating) |
193 | Super+Button3 (drag) | Resize window (floating) |
194
195 * Features
196 - *Dynamic Tiling Layout* with adjustable master/stack split
197 - Master area resizing (mfact)
198 - Multiple master windows support (nmaster)
199 - *Tag-Based Workspaces* (9 tags by default)
200 - Multi-tag viewing (see multiple tags at once)
201 - Sticky windows (window visible on multiple tags)
202 - *Multiple Layouts*
203 - Tiling (master/stack)
204 - Normie (floating-by-default)
205 - Monocle (fullscreen stacking)
206 - Grid (equal-sized grid)
207 - Tabbed (tabbed windows)
208 - *Lua Configuration System*
209 - Hot reload without restarting X (=Mod+Shift+R=)
210 - LSP support with type definitions and autocomplete
211 - No compilation needed - instant config changes
212 - *Built-in Status Bar* with modular block system
213 - Battery, RAM, datetime, shell commands, static text
214 - Custom colors, update intervals, and underlines
215 - Click-to-switch tags
216 - Multi-monitor support (one bar per monitor)
217 - *Advanced Window Management*
218 - Window focus cycling through stack
219 - Fullscreen mode
220 - Floating window support
221 - Mouse hover to focus (follow mouse)
222 - Border indicators for focused windows
223 - Configurable gaps (smartgaps support)
224 - Window rules (auto-tag, auto-float by class/title)
225 - *Multi-Monitor Support*
226 - RandR multi-monitor detection
227 - Independent tags per monitor
228 - Move windows between monitors
229 - *Keychord Support*
230 - Multi-key sequences (Emacs/Vim style)
231 - Example: =Mod+Space= then =T= to spawn terminal
232 - *Persistent State*
233 - Window tags persist across WM restarts
234 - Uses X11 properties for state storage
235
236 * Testing with Xephyr
237 Test OXWM in a nested X server without affecting your current session:
238
239 #+begin_src sh
240 zig build xephyr
241 #+end_src
242
243 This starts Xephyr on display :2 and launches OXWM inside it.
244
245 For multi-monitor testing:
246 #+begin_src sh
247 zig build xephyr-multi
248 #+end_src
249
250 Or manually:
251 #+begin_src sh
252 Xephyr -screen 1280x800 :2 &
253 DISPLAY=:2 zig build run
254 #+end_src
255
256 * Project Structure
257 #+begin_src sh
258 src/
259 ├── main.zig [Entry point - handles CLI args, config loading, WM init]
260 ├── client.zig [Client/window management]
261 ├── monitor.zig [Monitor handling and multi-monitor support]
262 ├── overlay.zig [Overlay rendering]
263 ├── animations.zig [Animation support]
264 │
265 ├── config/
266 │ ├── config.zig [Config struct and defaults]
267 │ └── lua.zig [Lua config parser - loads and executes config.lua]
268 │
269 ├── bar/
270 │ ├── bar.zig [Status bar with XFT support]
271 │ └── blocks/
272 │ ├── blocks.zig [Block system core]
273 │ ├── format.zig [Block formatting utilities]
274 │ ├── battery.zig [Battery status block]
275 │ ├── datetime.zig [Date/time formatting block]
276 │ ├── ram.zig [RAM usage block]
277 │ ├── cpu_temp.zig [CPU temperature block]
278 │ ├── shell.zig [Shell command execution block]
279 │ └── static.zig [Static text block]
280 │
281 ├── layouts/
282 │ ├── tiling.zig [Tiling layout with master/stack]
283 │ ├── monocle.zig [Fullscreen stacking layout]
284 │ ├── floating.zig [Floating layout]
285 │ └── scrolling.zig [Scrolling layout]
286 │
287 └── x11/
288 ├── xlib.zig [X11/Xlib bindings]
289 ├── display.zig [Display management]
290 └── events.zig [X11 event handling]
291
292 templates/
293 ├── config.lua [Default config with functional API]
294 └── oxwm.lua [LSP type definitions for autocomplete]
295 #+end_src
296
297 * Architecture Notes
298 ** Lua Configuration System
299 OXWM embeds a Lua 5.4 interpreter using Zig's C interop. The functional API is implemented in =src/config/lua.zig=:
300 - Each API function (e.g., =oxwm.border.set_width()=) is registered as a Lua function
301 - Functions modify the config state that accumulates settings
302 - When config execution completes, the final Config struct is produced
303 - Type definitions in =templates/oxwm.lua= provide LSP autocomplete and documentation
304
305 ** Tag System
306 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).
307
308 ** Status Bar
309 The bar uses a performance-optimized approach with a modular block system:
310 - Only redraws when invalidated
311 - Pre-calculates tag widths on creation
312 - Blocks update independently based on their configured intervals
313 - Supports custom colors and underline indicators
314 - Color schemes (normal/occupied/selected) control tag appearance
315 - Easily extensible - add new block types in src/bar/blocks/
316
317 ** Layout System
318 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.
319
320 * TODO Current Todo List:
321 ** PRIORITY High [0/4]
322 - [ ] Add Window Titles to Bar
323 - Show focused window title in status bar
324 - Truncate if too long
325 - Update on window focus change
326 - [ ] Add Horizontal Scroll Layout
327 - Master window on left, stack scrolls horizontally
328 - Alternative to vertical tiling
329 - [ ] Add Hide Empty Tag Numbers Option
330 - Option to hide tags with no windows
331 - Configurable via =oxwm.bar.set_hide_empty_tags(bool)=
332 - [ ] Add Swap Stack Bind
333 - Keybind to swap focused window with master
334 - Similar to dwm's zoom function (=Mod+Return=)
335 - Should work bidirectionally
336 * Development Roadmap
337 ** Current Focus (v0.11.3)
338 - Implement featuers such as systray to make the bar more robust.
339 - Improving core window management reliability
340 - Maintaining Lua config and bar features while simplifying internals
341
342 ** Completed Features [8/8]
343 - [X] Multi-monitor support with RandR
344 - [X] Multiple layouts (tiling, monocle, grid, tabbed, normie)
345 - [X] Master area resizing (mfact) and nmaster support
346 - [X] Window rules (per-program auto-tag, floating)
347 - [X] Lua configuration with hot-reload
348 - [X] Built-in status bar with modular blocks
349 - [X] Keychord support (multi-key sequences)
350 - [X] Tag persistence across restarts
351
352 ** Future Enhancements [/]
353 - [ ] Scratchpad functionality
354 - [ ] Dynamic monitor hotplugging (currently only on startup)
355 - [ ] External bar support (polybar, waybar compatibility)
356 - [ ] Additional layouts (deck, spiral, dwindle)
357
358 * License
359 [[https://www.gnu.org/licenses/gpl-3.0.en.html][GPL v3]]