tony / oxwm

Update documentation and build system from Rust to Zig, replace justfile with native zig build install/uninstall steps Browse files
tonybanters committed 2026-02-16 parent 0e1568b commit dc5a661eddbc78f5aaa0aa267c3a2dfc35d51cb3
Showing 4 changed files with 71 additions and 131 deletions. UnifiedSplit
+23 −0 build.zig
@@ -86,6 +86,29 @@ pub fn build(b: *std.Build) void {
86 86
87 const clean_step = b.step("clean", "Remove build artifacts"); 87 const clean_step = b.step("clean", "Remove build artifacts");
88 clean_step.dependOn(&b.addSystemCommand(&.{ "rm", "-rf", "zig-out", ".zig-cache" }).step); 88 clean_step.dependOn(&b.addSystemCommand(&.{ "rm", "-rf", "zig-out", ".zig-cache" }).step);
89 +
90 + const install_step = b.step("install-system", "Install oxwm system-wide (requires sudo)");
91 + install_step.dependOn(b.getInstallStep());
92 + install_step.dependOn(&b.addSystemCommand(&.{
93 + "sudo", "sh", "-c",
94 + "cp zig-out/bin/oxwm /usr/bin/oxwm && " ++
95 + "chmod +x /usr/bin/oxwm && " ++
96 + "mkdir -p /usr/share/xsessions && " ++
97 + "cp resources/oxwm.desktop /usr/share/xsessions/oxwm.desktop && " ++
98 + "mkdir -p /usr/share/man/man1 && " ++
99 + "cp resources/oxwm.1 /usr/share/man/man1/oxwm.1 && " ++
100 + "mkdir -p /usr/share/oxwm && " ++
101 + "cp templates/oxwm.lua /usr/share/oxwm/oxwm.lua && " ++
102 + "echo 'oxwm installed to /usr/bin/oxwm'",
103 + }).step);
104 +
105 + const uninstall_step = b.step("uninstall", "Uninstall oxwm from system");
106 + uninstall_step.dependOn(&b.addSystemCommand(&.{
107 + "sudo", "sh", "-c",
108 + "rm -f /usr/bin/oxwm /usr/share/xsessions/oxwm.desktop /usr/share/man/man1/oxwm.1 && " ++
109 + "rm -rf /usr/share/oxwm && " ++
110 + "echo 'oxwm uninstalled (config at ~/.config/oxwm preserved)'",
111 + }).step);
89 } 112 }
90 113
91 fn add_xephyr_run(b: *std.Build, exe: *std.Build.Step.Compile, multimon: bool) *std.Build.Step.Run { 114 fn add_xephyr_run(b: *std.Build, exe: *std.Build.Step.Compile, multimon: bool) *std.Build.Step.Run {
+0 −1 flake.nix
@@ -26,7 +26,6 @@
26 pkgs.zig 26 pkgs.zig
27 pkgs.zls 27 pkgs.zls
28 pkgs.alacritty 28 pkgs.alacritty
29 - pkgs.just
30 pkgs.xorg.xorgserver 29 pkgs.xorg.xorgserver
31 ]; 30 ];
32 shellHook = '' 31 shellHook = ''
+0 −43 justfile deleted file mode 100644
@@ -1,43 +0,0 @@
1 -build:
2 - zig build -Doptimize=ReleaseSafe
3 -
4 -install: build
5 - sudo cp zig-out/bin/oxwm /usr/bin/oxwm
6 - sudo cp resources/oxwm.desktop /usr/share/xsessions/oxwm.desktop
7 - sudo chmod +x /usr/bin/oxwm
8 - @echo "oxwm installed to /usr/bin/oxwm"
9 -
10 -checkinstall:
11 - checkinstall --pkgname oxwm --exclude /root -y just install
12 -
13 -uninstall:
14 - sudo rm -f /usr/bin/oxwm
15 - @echo "oxwm uninstalled"
16 - @echo "Your config at ~/.config/oxwm/ is preserved"
17 -
18 -clean:
19 - rm -rf zig-out .zig-cache
20 -
21 -test-clean:
22 - pkill Xephyr || true
23 - rm -rf ~/.config/oxwm
24 - Xephyr -screen 1280x800 :1 & sleep 1
25 - DISPLAY=:1 zig build run -- -c resources/config.lua
26 -
27 -test:
28 - zig build xephyr
29 -
30 -test-multimon:
31 - zig build xephyr-multi
32 -
33 -edit:
34 - $EDITOR ~/.config/oxwm/config.lua
35 -
36 -fmt:
37 - zig build fmt
38 -
39 -pre-commit: fmt build
40 - @echo "All checks passed!"
41 -
42 -run:
43 - zig build run
+48 −87 readme.org
@@ -4,7 +4,7 @@
4 [[file:./images/oxwm1.png]] 4 [[file:./images/oxwm1.png]]
5 5
6 * Table of Contents :toc: 6 * Table of Contents :toc:
7 -- [[#oxwm--dwm-but-better-and-oxidized][OXWM — DWM but Better (and oxidized)]] 7 +- [[#oxwm--dwm-but-better][OXWM — DWM but Better]]
8 - [[#installation][Installation]] 8 - [[#installation][Installation]]
9 - [[#nixos-with-flakes][NixOS (with Flakes)]] 9 - [[#nixos-with-flakes][NixOS (with Flakes)]]
10 - [[#arch-linux][Arch Linux]] 10 - [[#arch-linux][Arch Linux]]
@@ -33,8 +33,8 @@
33 - [[#future-enhancements-][Future Enhancements]] 33 - [[#future-enhancements-][Future Enhancements]]
34 - [[#license][License]] 34 - [[#license][License]]
35 35
36 -* OXWM — DWM but Better (and oxidized) 36 +* OXWM — DWM but Better
37 -A dynamic window manager written in Rust, 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. 37 +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.
38 38
39 *Documentation:* [[https://ox-docs.vercel.app/][ox-docs.vercel.app]] 39 *Documentation:* [[https://ox-docs.vercel.app/][ox-docs.vercel.app]]
40 40
@@ -112,8 +112,8 @@ cd oxwm
112 nix develop 112 nix develop
113 113
114 # Build and test 114 # Build and test
115 -cargo build 115 +zig build
116 -just test 116 +zig build test
117 #+end_src 117 #+end_src
118 118
119 ** Arch Linux 119 ** Arch Linux
@@ -127,7 +127,7 @@ This will automatically put a desktop session file into your xsessions directory
127 Manually: 127 Manually:
128 Install dependencies: 128 Install dependencies:
129 #+begin_src sh 129 #+begin_src sh
130 -sudo pacman -S rust cargo libx11 libxft freetype2 fontconfig pkg-config 130 +sudo pacman -S zig lua libx11 libxft freetype2 fontconfig libxinerama
131 #+end_src 131 #+end_src
132 See Build from source 132 See Build from source
133 133
@@ -135,13 +135,13 @@ See Build from source
135 #+begin_src sh 135 #+begin_src sh
136 git clone https://github.com/tonybanters/oxwm 136 git clone https://github.com/tonybanters/oxwm
137 cd oxwm 137 cd oxwm
138 -cargo build --release 138 +zig build -Doptimize=ReleaseFast
139 -sudo cp target/release/oxwm /usr/local/bin/ 139 +zig build install-system # installs to /usr/bin, adds desktop file and man page
140 #+end_src 140 #+end_src
141 141
142 -Or use the justfile: 142 +To uninstall:
143 #+begin_src sh 143 #+begin_src sh
144 -just install 144 +zig build uninstall
145 #+end_src 145 #+end_src
146 146
147 ** Setting up OXWM 147 ** Setting up OXWM
@@ -235,7 +235,7 @@ When contributing to OXWM:
235 235
236 1. Never commit your personal =~/.config/oxwm/config.lua= 236 1. Never commit your personal =~/.config/oxwm/config.lua=
237 2. Only modify =templates/config.lua= if adding new configuration options 237 2. Only modify =templates/config.lua= if adding new configuration options
238 -3. Test your changes with =just test= using Xephyr/Xwayland 238 +3. Test your changes with =zig build xephyr= using Xephyr or =zig build xwayland= using Xwayland
239 4. Document any new features or keybindings 239 4. Document any new features or keybindings
240 240
241 * Key Bindings 241 * Key Bindings
@@ -313,96 +313,57 @@ Default keybindings (fully customizable in =~/.config/oxwm/config.lua=):
313 Test OXWM in a nested X server without affecting your current session: 313 Test OXWM in a nested X server without affecting your current session:
314 314
315 #+begin_src sh 315 #+begin_src sh
316 -just test 316 +zig build xephyr
317 #+end_src 317 #+end_src
318 318
319 -This starts Xephyr on display :1 and launches OXWM inside it. 319 +This starts Xephyr on display :2 and launches OXWM inside it.
320 +
321 +For multi-monitor testing:
322 +#+begin_src sh
323 +zig build xephyr-multi
324 +#+end_src
320 325
321 Or manually: 326 Or manually:
322 #+begin_src sh 327 #+begin_src sh
323 -Xephyr -screen 1280x800 :1 & 328 +Xephyr -screen 1280x800 :2 &
324 -DISPLAY=:1 cargo run 329 +DISPLAY=:2 zig build run
325 #+end_src 330 #+end_src
326 331
327 * Project Structure 332 * Project Structure
328 #+begin_src sh 333 #+begin_src sh
329 src/ 334 src/
330 -├── bin/ 335 +├── main.zig [Entry point - handles CLI args, config loading, WM init]
331 -│ └── main.rs [Entry point - handles CLI args, config loading, WM init] 336 +├── client.zig [Client/window management]
332 -│ ├── main() [Parse args, load config, start WM] 337 +├── monitor.zig [Monitor handling and multi-monitor support]
333 -│ ├── load_config() [Lua config loading with auto-init] 338 +├── overlay.zig [Overlay rendering]
334 -│ └── init_config() [Create default config.lua + oxwm.lua] 339 +├── animations.zig [Animation support]
335 -│
336 -├── lib.rs [Library exports]
337 -│
338 -├── window_manager.rs [CORE - X11 event handling]
339 -│ ├── struct WindowManager
340 -│ │ ├── connection: RustConnection [X11 connection]
341 -│ │ ├── windows: Vec<Window> [All managed windows]
342 -│ │ ├── focused_window: Option<Window>
343 -│ │ ├── layout: Box<dyn Layout>
344 -│ │ ├── window_tags: HashMap<Window, TagMask>
345 -│ │ ├── selected_tags: TagMask
346 -│ │ └── bars: Vec<Bar> [Status bars (multi-monitor)]
347 -│ │
348 -│ ├── new() [Initialize WM, grab root, restore tags, scan windows]
349 -│ ├── run() [Main event loop with block updates]
350 -│ ├── handle_event() [Route X11 events]
351 -│ ├── try_reload_config() [Hot-reload Lua config]
352 -│ └── ... [Window/tag/focus management]
353 │ 340 │
354 ├── config/ 341 ├── config/
355 -│ ├── mod.rs [Config module exports] 342 +│ ├── config.zig [Config struct and defaults]
356 -│ ├── lua.rs [Lua config parser - loads and executes config.lua] 343 +│ └── lua.zig [Lua config parser - loads and executes config.lua]
357 -│ └── lua_api.rs [Functional Lua API implementation]
358 -│ ├── register_api() [Set up oxwm.* functions in Lua]
359 -│ ├── register_spawn() [oxwm.spawn()]
360 -│ ├── register_key_module() [oxwm.key.bind(), oxwm.key.chord()]
361 -│ ├── register_gaps_module() [oxwm.gaps.*]
362 -│ ├── register_border_module() [oxwm.border.*]
363 -│ ├── register_client_module() [oxwm.client.*]
364 -│ ├── register_layout_module() [oxwm.layout.*]
365 -│ ├── register_tag_module() [oxwm.tag.*]
366 -│ ├── register_bar_module() [oxwm.bar.*]
367 -│ └── register_misc() [oxwm.set_terminal(), etc.]
368 │ 344 │
369 ├── bar/ 345 ├── bar/
370 -│ ├── mod.rs [Re-exports: Bar, BlockCommand, BlockConfig] 346 +│ ├── bar.zig [Status bar with XFT support]
371 -│ ├── bar.rs
372 -│ │ ├── struct Bar [Status bar window with XFT support]
373 -│ │ ├── new() [Create bar X11 window, load font, init blocks]
374 -│ │ ├── draw() [Render tags + blocks with underlines]
375 -│ │ ├── update_blocks() [Update block content based on intervals]
376 -│ │ └── handle_click() [Detect which tag was clicked]
377 -│ ├── font.rs
378 -│ │ ├── struct Font [XFT font wrapper]
379 -│ │ └── draw_text() [Render text with color]
380 │ └── blocks/ 347 │ └── blocks/
381 -│ ├── mod.rs [Block trait, BlockConfig, BlockCommand enum] 348 +│ ├── blocks.zig [Block system core]
382 -│ ├── battery.rs [Battery status block] 349 +│ ├── format.zig [Block formatting utilities]
383 -│ ├── datetime.rs [Date/time formatting block] 350 +│ ├── battery.zig [Battery status block]
384 -│ ├── ram.rs [RAM usage block] 351 +│ ├── datetime.zig [Date/time formatting block]
385 -│ ├── shell.rs [Shell command execution block] 352 +│ ├── ram.zig [RAM usage block]
386 -│ └── static.rs [Static text block] 353 +│ ├── cpu_temp.zig [CPU temperature block]
387 -│ 354 +│ ├── shell.zig [Shell command execution block]
388 -├── keyboard/ 355 +│ └── static.zig [Static text block]
389 -│ ├── mod.rs [Re-exports]
390 -│ ├── keysyms.rs [X11 keysym constants]
391 -│ └── handlers.rs
392 -│ ├── enum KeyAction [All keyboard actions]
393 -│ ├── enum Arg [Action arguments]
394 -│ ├── struct KeyBinding [Keybinding + keychord support]
395 -│ └── struct KeyPress [Individual key press in chord]
396 │ 356 │
397 -├── layout/ 357 +├── layouts/
398 -│ ├── mod.rs [Layout trait definition] 358 +│ ├── tiling.zig [Tiling layout with master/stack]
399 -│ ├── tiling.rs [Tiling layout with master/stack] 359 +│ ├── monocle.zig [Fullscreen stacking layout]
400 -│ ├── monocle.rs [Fullscreen stacking layout] 360 +│ ├── floating.zig [Floating layout]
401 -│ ├── grid.rs [Equal-sized grid layout] 361 +│ └── scrolling.zig [Scrolling layout]
402 -│ ├── tabbed.rs [Tabbed container layout]
403 -│ └── normie.rs [Floating-by-default layout]
404 │ 362 │
405 -└── errors.rs [Error types: WmError, ConfigError, etc.] 363 +└── x11/
364 + ├── xlib.zig [X11/Xlib bindings]
365 + ├── display.zig [Display management]
366 + └── events.zig [X11 event handling]
406 367
407 templates/ 368 templates/
408 ├── config.lua [Default config with functional API] 369 ├── config.lua [Default config with functional API]
@@ -411,10 +372,10 @@ templates/
411 372
412 * Architecture Notes 373 * Architecture Notes
413 ** Lua Configuration System 374 ** Lua Configuration System
414 -OXWM uses mlua to embed a Lua interpreter. The functional API is implemented in =src/config/lua_api.rs=: 375 +OXWM embeds a Lua 5.4 interpreter using Zig's C interop. The functional API is implemented in =src/config/lua.zig=:
415 - Each API function (e.g., =oxwm.border.set_width()=) is registered as a Lua function 376 - Each API function (e.g., =oxwm.border.set_width()=) is registered as a Lua function
416 -- Functions modify a shared ConfigBuilder that accumulates settings 377 +- Functions modify the config state that accumulates settings
417 -- When config execution completes, the builder produces the final Config struct 378 +- When config execution completes, the final Config struct is produced
418 - Type definitions in =templates/oxwm.lua= provide LSP autocomplete and documentation 379 - Type definitions in =templates/oxwm.lua= provide LSP autocomplete and documentation
419 380
420 ** Tag System 381 ** Tag System