tony / oxwm

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