tony / oxwm

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