tony / oxwm

Branch: faf793b
Switch branches/tags
master
tonybtw Migration to lua. faf793b 2025-11-08
390 lines · 14.6 KB Rendered Raw Blame History
1 #+AUTHOR: Tony
2 #+STARTUP: overview
3
4 [[file:./images/oxwm1.png]]
5
6 * Table of Contents :toc:
7 - [[#oxwm--dwm-but-better-and-oxidized][OXWM — DWM but Better (and oxidized)]]
8 - [[#installation][Installation]]
9 - [[#nixos-with-flakes][NixOS (with Flakes)]]
10 - [[#arch-linux][Arch Linux]]
11 - [[#building-from-source][Building from Source]]
12 - [[#setting-up-oxwm][Setting up OXWM]]
13 - [[#configuration][Configuration]]
14 - [[#contributing][Contributing]]
15 - [[#key-bindings][Key Bindings]]
16 - [[#features][Features]]
17 - [[#testing-with-xephyr][Testing with Xephyr]]
18 - [[#project-structure][Project Structure]]
19 - [[#architecture-notes][Architecture Notes]]
20 - [[#tag-system][Tag System]]
21 - [[#status-bar][Status Bar]]
22 - [[#layout-system][Layout System]]
23 - [[#current-todo-list][Current Todo List:]]
24 - [[#priority-high-02][PRIORITY High]]
25 - [[#priority-medium-14][PRIORITY Medium]]
26 - [[#priority-low-11][PRIORITY Low]]
27 - [[#development-roadmap][Development Roadmap]]
28 - [[#current-focus][Current Focus]]
29 - [[#future-enhancements][Future Enhancements]]
30 - [[#license][License]]
31
32 * OXWM — DWM but Better (and oxidized)
33 A dynamic window manager written in Rust, inspired by dwm but designed to evolve on its own. Configuration is done in Rust source code, ditching the suckless philosophy of *"edit + recompile."*, and instead focusing on lowering friction for users, with sane defaults and no arbitrary elitism enforcing bad variable names and bad file structure topology.
34
35 * Installation
36 ** NixOS (with Flakes)
37 *** Adding OXWM to your flake inputs
38 Add oxwm to your =flake.nix= inputs:
39
40 #+begin_src nix
41 {
42 inputs = {
43 nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
44 oxwm.url = "github:tonybanters/oxwm";
45 oxwm.inputs.nixpkgs.follows = "nixpkgs";
46 };
47
48 outputs = { self, nixpkgs, oxwm, ... }: {
49 nixosConfigurations.yourhost = nixpkgs.lib.nixosSystem {
50 system = "x86_64-linux";
51 modules = [
52 ./configuration.nix
53 oxwm.nixosModules.default
54 ];
55 };
56 };
57 }
58 #+end_src
59
60 *** Enabling OXWM in configuration.nix
61 Add this to your =configuration.nix=:
62
63 #+begin_src nix
64 { config, pkgs, ... }:
65
66 {
67 services.xserver = {
68 enable = true;
69
70 windowManager.oxwm.enable = true;
71 };
72
73 # Recommended: Install a display manager
74 services.xserver.displayManager.lightdm.enable = true;
75 # Or use another display manager like sddm, gdm, etc.
76 }
77 #+end_src
78
79 *** Initialize your config
80 After rebuilding your system with =sudo nixos-rebuild switch=, log in via your display manager.
81
82 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=.
83
84 *** Advanced: Using a specific oxwm version
85 If you want to pin or customize the oxwm package:
86
87 #+begin_src nix
88 {
89 services.xserver.windowManager.oxwm = {
90 enable = true;
91 # Use a specific version or build with custom options
92 package = oxwm.packages.${pkgs.system}.default;
93 };
94 }
95 #+end_src
96
97 *** Development setup with Nix
98 For development, use the provided dev shell:
99
100 #+begin_src sh
101 # Clone the repository
102 git clone https://github.com/tonybanters/oxwm
103 cd oxwm
104
105 # Enter the development environment
106 nix develop
107
108 # Build and test
109 cargo build
110 just test
111 #+end_src
112
113 ** Arch Linux
114
115 AUR: [[https://aur.archlinux.org/packages/oxwm-git][AUR URL]]
116 #+begin_src
117 yay -S oxwm-git
118 #+end_src
119 This will automatically put a desktop session file into your xsessions directory.
120
121 Manually:
122 Install dependencies:
123 #+begin_src sh
124 sudo pacman -S rust cargo libx11 libxft freetype2 fontconfig pkg-config
125 #+end_src
126 See Build from source
127
128 ** Building from Source
129 #+begin_src sh
130 git clone https://github.com/tonybanters/oxwm
131 cd oxwm
132 cargo build --release
133 sudo cp target/release/oxwm /usr/local/bin/
134 #+end_src
135
136 Or use the justfile:
137 #+begin_src sh
138 just install
139 #+end_src
140
141 ** Setting up OXWM
142 *** Without a display manager (startx)
143 Add the following to your =~/.xinitrc=:
144 #+begin_src sh
145 exec oxwm
146 #+end_src
147
148 Then start X with:
149 #+begin_src sh
150 startx
151 #+end_src
152
153 *** With a display manager
154 If using a display manager (LightDM, GDM, SDDM), OXWM should appear in the session list after installation.
155
156 * Configuration
157 OXWM was inspired by dwm, but ditched the suckless philosophy. This philosophy quite literally discourages users from using the software for the sake of 'elitism'. I find that quite nonsensical, so I went ahead and created this project to be user friendly. The configuration is done by editing =~/.config/oxwm/config.lua= and the binary can be reloaded with a hotkey (Super+Shift+R by default).
158
159 Edit =~/.config/oxwm/config.lua= to customize:
160 - Keybindings
161 - Colors and appearance
162 - Status bar blocks
163 - Gaps and borders
164 - Terminal and applications
165
166 After making changes, reload OXWM with =Mod+Shift+R=
167
168 ** Migrating from RON
169 If you have an old RON config (=config.ron=), use the migration tool to automatically convert it:
170
171 #+begin_src sh
172 oxwm --migrate
173 # Or specify a path:
174 oxwm --migrate ~/.config/oxwm/config.ron
175 #+end_src
176
177 This will convert your =config.ron= to =config.lua=, preserving all your settings. Your old config will remain intact for backup.
178
179 * Contributing
180 When contributing to OXWM:
181
182 1. Never commit your personal =~/.config/oxwm/config.lua=
183 2. Only modify =templates/config.lua= if adding new configuration options
184 3. Test your changes with =just test= using Xephyr/Xwayland
185 4. Document any new features or keybindings
186
187 * Key Bindings
188 Default keybindings (customizable in config.rs):
189
190 | Binding | Action |
191 |-------------------+-------------------------|
192 | Super+Return | Spawn terminal |
193 | Super+J/K | Cycle focus down/up |
194 | Super+Q | Kill focused window |
195 | Super+Shift+Q | Quit WM |
196 | Super+Shift+R | Hot reload WM |
197 | Super+1-9 | View tag 1-9 |
198 | Super+Shift+1-9 | Move window to tag 1-9 |
199 | Super+S | Screenshot (maim) |
200 | Super+D | dmenu launcher |
201 | Super+A | Toggle gaps |
202 | Super+Shift+F | Toggle fullscreen |
203 | Super+Shift+Space | Toggle floating |
204
205 * Features
206 - Dynamic tiling layout with master/stack
207 - Tag-based workspaces (9 tags by default)
208 - Configurable gaps between windows
209 - Status bar with modular block system
210 - Battery, RAM, datetime, shell commands
211 - Custom colors and update intervals
212 - Click-to-switch tags
213 - Window focus cycling
214 - Hot reload without restarting X
215 - Persistent window tags across restarts
216 - Mouse hover to focus
217 - Border indicators for focused windows
218 - Fullscreen mode
219 - Move Windows with Super HJKL
220
221 * Testing with Xephyr
222 Test OXWM in a nested X server without affecting your current session:
223
224 #+begin_src sh
225 just test
226 #+end_src
227
228 This starts Xephyr on display :1 and launches OXWM inside it.
229
230 Or manually:
231 #+begin_src sh
232 Xephyr -screen 1280x800 :1 &
233 DISPLAY=:1 cargo run
234 #+end_src
235
236 * Project Structure
237 #+begin_src sh
238 src/
239 ├── main.rs
240 │ └── main()
241 │ └── Creates WindowManager and calls .run()
242 │
243 ├── window_manager.rs [CORE - X11 event handling]
244 │ ├── struct WindowManager
245 │ │ ├── connection: RustConnection [X11 connection]
246 │ │ ├── windows: Vec<Window> [All managed windows]
247 │ │ ├── focused_window: Option<Window>
248 │ │ ├── layout: Box<dyn Layout>
249 │ │ ├── window_tags: HashMap<Window, TagMask>
250 │ │ ├── selected_tags: TagMask
251 │ │ └── bar: Bar [Status bar]
252 │ │
253 │ ├── new() [Initialize WM, grab root, restore tags, scan windows]
254 │ ├── run() [Main event loop with block updates]
255 │ ├── handle_event() [Route X11 events]
256 │ │ ├── MapRequest → add window, apply layout, update bar, save tag
257 │ │ ├── UnmapNotify → remove window, update bar
258 │ │ ├── DestroyNotify → remove window, update bar
259 │ │ ├── KeyPress → get action, handle it (includes Restart)
260 │ │ ├── ButtonPress → handle bar clicks
261 │ │ └── Expose → redraw bar
262 │ ├── handle_key_action() [Execute keyboard actions]
263 │ ├── get_saved_selected_tags() [Restore selected tags from _NET_CURRENT_DESKTOP]
264 │ ├── save_selected_tags() [Persist selected tags to root window]
265 │ ├── get_saved_tag() [Restore window tag from _NET_CLIENT_INFO]
266 │ ├── save_client_tag() [Persist window tag to window property]
267 │ ├── scan_existing_windows() [Manage windows on startup]
268 │ ├── remove_window() [Remove from Vec, reapply layout]
269 │ ├── set_focus() [Focus window, update visuals]
270 │ ├── cycle_focus() [Move focus to next/prev window]
271 │ ├── view_tag() [Switch to tag/workspace, update visibility]
272 │ ├── move_to_tag() [Move window to tag]
273 │ ├── update_bar() [Calculate occupied tags, redraw bar]
274 │ ├── update_focus_visuals() [Set border colors]
275 │ ├── update_window_visibility() [Map/unmap windows based on tags]
276 │ └── apply_layout() [Position all windows below bar]
277 │
278 ├── config.rs [CONFIGURATION - all settings here]
279 │ ├── BORDER_WIDTH, BORDER_FOCUSED, BORDER_UNFOCUSED
280 │ ├── FONT [XFT font string]
281 │ ├── TAG_COUNT, TAGS [Workspace configuration]
282 │ ├── TERMINAL, MODKEY
283 │ ├── ColorScheme [Foreground, background, border colors]
284 │ ├── SCHEME_NORMAL, SCHEME_OCCUPIED, SCHEME_SELECTED
285 │ ├── KEYBINDINGS [All keybinds as const array]
286 │ └── STATUS_BLOCKS [Block configurations with format, command, interval]
287 │
288 ├── bar/
289 │ ├── mod.rs [Re-exports: Bar, BlockCommand, BlockConfig]
290 │ ├── bar.rs
291 │ │ ├── struct Bar [Status bar window with XFT support]
292 │ │ ├── new() [Create bar X11 window, load font, init blocks]
293 │ │ ├── draw() [Render tags + blocks with underlines]
294 │ │ ├── update_blocks() [Update block content based on intervals]
295 │ │ ├── handle_click() [Detect which tag was clicked]
296 │ │ └── invalidate() [Mark bar as needing redraw]
297 │ ├── font.rs
298 │ │ ├── struct Font [XFT font wrapper]
299 │ │ ├── struct FontDraw [XFT drawing context]
300 │ │ └── draw_text() [Render text with color]
301 │ └── blocks/
302 │ ├── mod.rs [Block trait, BlockConfig, BlockCommand enum]
303 │ ├── battery.rs [Battery status block]
304 │ ├── datetime.rs [Date/time formatting block]
305 │ └── shell.rs [Shell command execution block]
306 │
307 ├── keyboard/
308 │ ├── mod.rs [Re-exports]
309 │ ├── keycodes.rs [Key constants: Q, J, RETURN, etc]
310 │ └── handlers.rs
311 │ ├── enum KeyAction [Spawn, KillClient, FocusStack, ViewTag, Restart, etc]
312 │ ├── enum Arg [None, Int, Str, Array]
313 │ ├── struct Key [Keybinding definition]
314 │ ├── setup_keybinds() [Register keys with X11]
315 │ └── handle_key_press() [Parse KeyPressEvent → KeyAction]
316 │
317 └── layout/
318 ├── mod.rs [Layout trait definition]
319 └── tiling.rs
320 └── TilingLayout::arrange() [Calculate window positions]
321 #+end_src
322
323 * Architecture Notes
324 ** Tag System
325 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).
326
327 ** Status Bar
328 The bar uses a performance-optimized approach with a modular block system:
329 - Only redraws when invalidated
330 - Pre-calculates tag widths on creation
331 - Blocks update independently based on their configured intervals
332 - Supports custom colors and underline indicators
333 - Easily extensible - add new block types in src/bar/blocks/
334
335 ** Layout System
336 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.
337
338 * TODO Current Todo List:
339 ** PRIORITY High [0/2]
340 - [ ] Convert keycodes to keysyms for cross-keyboard compatibility
341 - Current hardcoded keycodes only work on specific keyboards
342 - Need to use XKeysymToKeycode() for runtime conversion
343 - Follow DWM's approach: keysym → keycode conversion
344 - [ ] Fix fullscreen to persist across tags
345 - Fullscreen state should be maintained when switching tags
346 - Window should remain fullscreen when returning to its tag
347
348 ** PRIORITY Medium [1/4]
349 - [ ] Add keybindings to increase/decrease window size
350 - Master area resize (Mod+H / Mod+L)
351 - Individual window resize for floating windows
352 - [ ] Keychords:
353 - Desired Behaviour:
354 #+begin_src rust
355 // Keychord: Mod+f, then f (same key twice)
356 (keys: [
357 (modifiers: [Mod], key: F),
358 (modifiers: [], key: F),
359 ], action: Spawn, arg: "repos-dmenu.sh"),
360
361 #+end_src
362 - [X] Fix cursor on hover for bar
363 - Bar should show pointer cursor on hover
364 - Indicate clickable tag areas
365 - [ ] Add guess_terminal() function to default config.rs
366 - Auto-detect available terminal emulator
367 - Priority order: st → alacritty → kitty → wezterm → xterm
368 - Fallback to xterm if none found
369
370 ** PRIORITY Low [1/1]
371 - [X] Create AUR package
372 - Write PKGBUILD
373 - Submit to AUR
374 - Add installation instructions to README
375 * Development Roadmap
376 ** Current Focus
377 - Multi-monitor support
378 - Additional layouts (monocle, floating)
379 - Master area resizing
380 - Window swapping in layout
381
382 ** Future Enhancements
383 - Per-window floating behavior
384 - Per-program rules (auto-tag assignment, floating rules)
385 - External bar support (polybar, etc)
386 - Scratchpad functionality
387 - Window minimize/restore
388
389 * License
390 [[https://www.gnu.org/licenses/gpl-3.0.en.html][GPL v3]]