tony / oxwm

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