tony / oxwm

Updated readme. Browse files
tonybtw committed 2025-10-09 parent 98a1994 commit 9ecd575fe9f2a94ef2fe8b1193abfba4fb7835ef
Showing 1 changed file with 137 additions and 250 deletions. UnifiedSplit
+137 −250 readme.org
@@ -2,142 +2,89 @@
2 #+STARTUP: overview 2 #+STARTUP: overview
3 3
4 * Table of Contents :toc: 4 * Table of Contents :toc:
5 -- [[#oxwm--dwm-but-better-and-oxidized][OXWM — DWM but Better (and oxidized)]] 5 +- [[#oxwm][OXWM]]
6 -- [[#project-structure][Project Structure]] 6 +- [[#installation][Installation]]
7 -- [[#event-flow][Event Flow]] 7 + - [[#arch-linux][Arch Linux]]
8 + - [[#building-from-source][Building from Source]]
9 + - [[#setting-up-oxwm][Setting up OXWM]]
10 +- [[#configuration][Configuration]]
11 +- [[#contributing][Contributing]]
8 - [[#key-bindings][Key Bindings]] 12 - [[#key-bindings][Key Bindings]]
9 -- [[#-installation--running-with-nix-flakes][⚙ Installation — Running with Nix Flakes]] 13 +- [[#features][Features]]
10 -- [[#testing-xephyr-with-justfile][Testing Xephyr with Justfile]] 14 +- [[#testing-with-xephyr][Testing with Xephyr]]
11 -- [[#current-status][Current Status]] 15 +- [[#project-structure][Project Structure]]
12 - - [[#working-features][Working Features]]
13 - - [[#immediate-next-steps][Immediate Next Steps]]
14 - - [[#long-term-roadmap][Long Term Roadmap]]
15 -- [[#oxwm-development-todo][OXWM Development Todo]]
16 - - [[#core-window-management-22][Core Window Management]]
17 - - [[#tag-system-33][Tag System]]
18 - - [[#status-bar-22][Status Bar]]
19 - - [[#bar-enhancements-33][Bar Enhancements]]
20 - - [[#key-system-improvements-22][Key System Improvements]]
21 - - [[#layout-system-05][Layout System]]
22 - - [[#advanced-features-04][Advanced Features]]
23 - - [[#polish--features][Polish & Features]]
24 - [[#architecture-notes][Architecture Notes]] 16 - [[#architecture-notes][Architecture Notes]]
25 - - [[#tag-system][Tag System]] 17 +- [[#development-roadmap][Development Roadmap]]
26 - - [[#bar-design][Bar Design]]
27 - - [[#configuration-philosophy][Configuration Philosophy]]
28 - [[#license][License]] 18 - [[#license][License]]
29 19
30 -* OXWM — DWM but Better (and oxidized) 20 +* OXWM
31 -A dynamic window manager written in Rust, inspired by dwm but designed to evolve 21 +A dynamic tiling window manager written in Rust, inspired by dwm. Configuration is done in Rust source code, keeping with the suckless philosophy of "edit and recompile."
32 -on its own. Configuration is done in Rust source code, keeping with the suckless
33 -philosophy of *"edit + recompile."*
34 22
35 -* Project Structure 23 +* Installation
24 +** Arch Linux
25 +Install dependencies:
26 +#+begin_src sh
27 +sudo pacman -S rust cargo libx11 libxft freetype2 fontconfig pkg-config
28 +#+end_src
36 29
30 +** Building from Source
37 #+begin_src sh 31 #+begin_src sh
38 -src/ 32 +git clone https://github.com/tonybanters/oxwm
39 -├── main.rs 33 +cd oxwm
40 -│ └── main() 34 +cargo build --release
41 -│ └── Creates WindowManager and calls .run() 35 +sudo cp target/release/oxwm /usr/local/bin/
42 -│ 36 +#+end_src
43 -├── window_manager.rs [CORE - X11 event handling] 37 +
44 -│ ├── struct WindowManager 38 +Or use the justfile:
45 -│ │ ├── connection: RustConnection [X11 connection] 39 +#+begin_src sh
46 -│ │ ├── windows: Vec<Window> [All managed windows] 40 +just install
47 -│ │ ├── focused_window: Option<Window> 41 +#+end_src
48 -│ │ ├── layout: Box<dyn Layout> 42 +
49 -│ │ ├── window_tags: HashMap<Window, TagMask> 43 +** Setting up OXWM
50 -│ │ ├── selected_tags: TagMask 44 +Add the following to your =~/.xinitrc=:
51 -│ │ └── bar: Bar [Status bar] 45 +#+begin_src sh
52 -│ │ 46 +exec oxwm
53 -│ ├── new() [Initialize WM, grab root, restore tags, scan windows] 47 +#+end_src
54 -│ ├── run() [Main event loop with block updates] 48 +
55 -│ ├── handle_event() [Route X11 events] 49 +Then start X with:
56 -│ │ ├── MapRequest → add window, apply layout, update bar, save tag 50 +#+begin_src sh
57 -│ │ ├── UnmapNotify → remove window, update bar 51 +startx
58 -│ │ ├── DestroyNotify → remove window, update bar 52 +#+end_src
59 -│ │ ├── KeyPress → get action, handle it (includes Restart) 53 +
60 -│ │ ├── ButtonPress → handle bar clicks 54 +* Configuration
61 -│ │ └── Expose → redraw bar 55 +OXWM follows the suckless philosophy: configuration is done by editing =src/config.rs= and recompiling.
62 -│ ├── handle_key_action() [Execute keyboard actions] 56 +
63 -│ ├── get_saved_selected_tags() [Restore selected tags from _NET_CURRENT_DESKTOP] 57 +On first build, =config.rs= is automatically created from =src/default_config.rs=. Your =config.rs= is gitignored, so you can customize it without worrying about merge conflicts.
64 -│ ├── save_selected_tags() [Persist selected tags to root window] 58 +
65 -│ ├── get_saved_tag() [Restore window tag from _NET_CLIENT_INFO] 59 +To reset your config to defaults:
66 -│ ├── save_client_tag() [Persist window tag to window property] 60 +#+begin_src sh
67 -│ ├── scan_existing_windows() [Manage windows on startup] 61 +just reset-config
68 -│ ├── remove_window() [Remove from Vec, reapply layout] 62 +#+end_src
69 -│ ├── set_focus() [Focus window, update visuals] 63 +
70 -│ ├── cycle_focus() [Move focus to next/prev window] 64 +Edit =src/config.rs= to customize:
71 -│ ├── view_tag() [Switch to tag/workspace, update visibility] 65 +- Keybindings
72 -│ ├── move_to_tag() [Move window to tag] 66 +- Colors and appearance
73 -│ ├── update_bar() [Calculate occupied tags, redraw bar] 67 +- Status bar blocks
74 -│ ├── update_focus_visuals() [Set border colors] 68 +- Gaps and borders
75 -│ ├── update_window_visibility() [Map/unmap windows based on tags] 69 +- Terminal and applications
76 -│ └── apply_layout() [Position all windows below bar] 70 +
77 -│ 71 +After making changes:
78 -├── config.rs [CONFIGURATION - all settings here] 72 +#+begin_src sh
79 -│ ├── BORDER_WIDTH, BORDER_FOCUSED, BORDER_UNFOCUSED 73 +just install
80 -│ ├── FONT [XFT font string]
81 -│ ├── TAG_COUNT, TAGS [Workspace configuration]
82 -│ ├── TERMINAL, MODKEY
83 -│ ├── ColorScheme [Foreground, background, border colors]
84 -│ ├── SCHEME_NORMAL, SCHEME_OCCUPIED, SCHEME_SELECTED
85 -│ ├── KEYBINDINGS [All keybinds as const array]
86 -│ └── STATUS_BLOCKS [Block configurations with format, command, interval]
87 -│
88 -├── bar/
89 -│ ├── mod.rs [Re-exports: Bar, BlockCommand, BlockConfig]
90 -│ ├── bar.rs
91 -│ │ ├── struct Bar [Status bar window with XFT support]
92 -│ │ ├── new() [Create bar X11 window, load font, init blocks]
93 -│ │ ├── draw() [Render tags + blocks with underlines]
94 -│ │ ├── update_blocks() [Update block content based on intervals]
95 -│ │ ├── handle_click() [Detect which tag was clicked]
96 -│ │ └── invalidate() [Mark bar as needing redraw]
97 -│ ├── font.rs
98 -│ │ ├── struct Font [XFT font wrapper]
99 -│ │ ├── struct FontDraw [XFT drawing context]
100 -│ │ └── draw_text() [Render text with color]
101 -│ └── blocks/
102 -│ ├── mod.rs [Block trait, BlockConfig, BlockCommand enum]
103 -│ ├── battery.rs [Battery status block]
104 -│ ├── datetime.rs [Date/time formatting block]
105 -│ └── shell.rs [Shell command execution block]
106 -│
107 -├── keyboard/
108 -│ ├── mod.rs [Re-exports]
109 -│ ├── keycodes.rs [Key constants: Q, J, RETURN, etc]
110 -│ └── handlers.rs
111 -│ ├── enum KeyAction [Spawn, KillClient, FocusStack, ViewTag, Restart, etc]
112 -│ ├── enum Arg [None, Int, Str, Array]
113 -│ ├── struct Key [Keybinding definition]
114 -│ ├── setup_keybinds() [Register keys with X11]
115 -│ └── handle_key_press() [Parse KeyPressEvent → KeyAction]
116 -│
117 -└── layout/
118 - ├── mod.rs [Layout trait definition]
119 - └── tiling.rs
120 - └── TilingLayout::arrange() [Calculate window positions]
121 #+end_src 74 #+end_src
122 75
123 -* Event Flow 76 +Then reload OXWM with Alt+Shift+R.
124 77
125 -1. X11 event arrives → run() receives it 78 +* Contributing
126 -2. handle_event() matches event type 79 +When contributing to OXWM:
127 -3. For KeyPress: 80 +
128 - - keyboard::handle_key_press() → KeyAction 81 +1. Never commit your personal =src/config.rs= (it's gitignored)
129 - - handle_key_action() executes action 82 +2. Only modify =src/default_config.rs= if adding new configuration options
130 - - update_bar() if tags/windows changed 83 +3. Test your changes with =just test= using Xephyr
131 -4. For Map/Unmap: 84 +4. Document any new features or keybindings
132 - - Modify windows Vec and window_tags HashMap
133 - - apply_layout() repositions everything (accounting for bar)
134 - - update_bar() shows occupied tags
135 - - update_focus_visuals() redraws borders
136 -5. For ButtonPress on bar:
137 - - bar.handle_click() determines clicked tag
138 - - view_tag() switches workspace
139 85
140 * Key Bindings 86 * Key Bindings
87 +Default keybindings (customizable in config.rs):
141 88
142 | Binding | Action | 89 | Binding | Action |
143 |-----------------+-------------------------| 90 |-----------------+-------------------------|
@@ -149,146 +96,86 @@ src/
149 | Alt+1-9 | View tag 1-9 | 96 | Alt+1-9 | View tag 1-9 |
150 | Alt+Shift+1-9 | Move window to tag 1-9 | 97 | Alt+Shift+1-9 | Move window to tag 1-9 |
151 | Alt+S | Screenshot (maim) | 98 | Alt+S | Screenshot (maim) |
152 -| Alt+D | Application launcher | 99 +| Alt+D | dmenu launcher |
100 +| Alt+A | Toggle gaps |
101 +| Alt+Shift+F | Toggle fullscreen |
102 +
103 +* Features
104 +- Dynamic tiling layout with master/stack
105 +- Tag-based workspaces (9 tags by default)
106 +- Configurable gaps between windows
107 +- Status bar with modular block system
108 + - Battery, RAM, datetime, shell commands
109 + - Custom colors and update intervals
110 + - Click-to-switch tags
111 +- Window focus cycling
112 +- Hot reload without restarting X
113 +- Persistent window tags across restarts
114 +- Mouse hover to focus
115 +- Border indicators for focused windows
116 +- Fullscreen mode
153 117
154 -* ⚙ Installation — Running with Nix Flakes 118 +* Testing with Xephyr
155 -You can set up a reproducible development environment with Rust, Cargo, Xephyr, xterm, and 119 +Test OXWM in a nested X server without affecting your current session:
156 -just by using the flake.
157 120
158 #+begin_src sh 121 #+begin_src sh
159 -git clone https://github.com/tonybanters/oxwm 122 +just test
160 -cd oxwm
161 -
162 -# enter the dev shell
163 -nix develop
164 -
165 -# build normally
166 -cargo build
167 #+end_src 123 #+end_src
168 124
169 -* Testing Xephyr with Justfile 125 +This starts Xephyr on display :1 and launches OXWM inside it.
170 -The =justfile= includes a =test= recipe that starts Xephyr on =:1=, launches
171 -test clients (xterm, xclock), and runs oxwm in the foreground.
172 126
127 +Or manually:
173 #+begin_src sh 128 #+begin_src sh
174 -# inside nix develop 129 +Xephyr -screen 1280x800 :1 &
175 -just test 130 +DISPLAY=:1 cargo run
176 #+end_src 131 #+end_src
177 132
178 -This should open a new Xephyr window. oxwm will attach to it and log X11 133 +* Project Structure
179 -events in your host terminal. Clients like xterm/xclock will appear inside Xephyr. 134 +#+begin_src sh
180 - 135 +src/
181 -* Current Status 136 +├── main.rs Entry point
182 -** Working Features 137 +├── window_manager.rs Core X11 event handling and window management
183 -- ✓ X11 event handling and window management 138 +├── default_config.rs Default configuration (reference)
184 -- ✓ Tag system (9 workspaces) with keyboard switching 139 +├── config.rs User configuration (gitignored, auto-generated)
185 -- ✓ Window focus cycling (Alt+J/K) 140 +├── bar/
186 -- ✓ Tiling layout with border indicators 141 +│ ├── bar.rs Status bar rendering with XFT
187 -- ✓ Status bar showing tags 142 +│ ├── font.rs Font handling
188 - - Visual indicators: selected (white), occupied (gray line), empty (dim) 143 +│ └── blocks/ Modular status bar widgets
189 - - Click-to-switch tags 144 +├── keyboard/
190 - - Performance-optimized redrawing 145 +│ ├── handlers.rs Keybinding actions
191 -- ✓ Basic keybindings (spawn, kill, focus, tags) 146 +│ └── keycodes.rs X11 keycode constants
192 -- ✓ Configuration via Rust constants in config.rs 147 +└── layout/
193 -- ✓ Hot reload functionality (Alt+Shift+R) 148 + └── tiling.rs Tiling layout algorithm
194 -- ✓ Persistent window tags across restarts 149 +#+end_src
195 -- ✓ Status bar blocks system
196 - - DateTime, Battery, Shell command blocks
197 - - Configurable colors and update intervals
198 - - Underline indicators for blocks
199 - - Proper spacing between blocks
200 - - Hackable block system for custom widgets
201 -- ✓ dmenu integration (Alt+D)
202 -
203 -** Immediate Next Steps
204 -- [ ] Mouse hover to focus windows
205 -- [ ] Configurable gaps between windows (vanitygaps-style)
206 -- [ ] Decide on reload behavior (should it auto-rebuild?)
207 -
208 -** Long Term Roadmap
209 -- [ ] Multi-monitor support
210 -- [ ] Additional layouts (monocle, floating, etc.)
211 -- [ ] Per-window floating behavior
212 -- [ ] Per-program rules (auto-tag assignment, floating rules)
213 -- [ ] Master area resizing
214 -- [ ] Window swapping in layout
215 -- [ ] External bar support (polybar, lemonbar, etc.)
216 -
217 -* OXWM Development Todo
218 -** DONE Core Window Management [2/2]
219 -- [X] Fix layout after program is closed (handle UnmapNotify events)
220 - - [X] Add UnmapNotify to event handling
221 - - [X] Remove closed windows from windows vector
222 - - [X] Re-apply layout after window removal
223 -- [X] Add keybind to swap focus between windows
224 - - [X] Track focused window in WindowManager struct
225 - - [X] Implement focus cycling logic
226 - - [X] Add visual focus indication (borders/colors)
227 -
228 -** DONE Tag System [3/3]
229 -- [X] Implement tag/workspace system (9 tags)
230 -- [X] Keybinds to switch tags (Alt+1-9)
231 -- [X] Keybinds to move windows to tags (Alt+Shift+1-9)
232 -
233 -** DONE Status Bar [2/2]
234 -- [X] Create basic bar window at screen top
235 -- [X] Display tag indicators with state (selected/occupied/empty)
236 -
237 -** DONE Bar Enhancements [3/3]
238 -- [X] Add status text area (right side of bar)
239 -- [X] Implement clock widget
240 -- [X] Add system information widgets
241 -
242 -** DONE Key System Improvements [2/2]
243 -- [X] dmenu integration for application launching
244 -- [X] More spawn commands in config (screenshot, volume, etc.)
245 -
246 -** TODO Layout System [0/5]
247 -- [ ] Mouse hover to focus windows
248 -- [ ] Configurable gaps between windows (vanitygaps-style)
249 -- [ ] Add monocle layout
250 -- [ ] Add floating layout mode
251 -- [ ] Handle window resize requests properly
252 -
253 -** TODO Advanced Features [0/4]
254 -- [ ] Decide on reload behavior (auto-rebuild vs manual)
255 -- [ ] Multi-monitor support
256 -- [ ] Per-window rules (floating, tag assignment)
257 -- [ ] Master area resizing keybinds
258 -
259 -** Polish & Features
260 -- [ ] Clean window destruction/cleanup
261 -- [ ] Handle edge cases (empty window list, invalid windows)
262 -- [ ] Better error messages and logging
263 -- [ ] Proper font rendering in bar (currently using basic X11 text)
264 150
265 * Architecture Notes 151 * Architecture Notes
266 ** Tag System 152 ** Tag System
267 -Tags are implemented as bitmasks (TagMask = u32), allowing windows to belong to 153 +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).
268 -multiple tags simultaneously (though current UI only supports single tags).
269 -Each window has an associated TagMask in window_tags HashMap. Tags persist across
270 -WM restarts using X11 properties (_NET_CURRENT_DESKTOP for selected tags,
271 -_NET_CLIENT_INFO for per-window tags).
272 154
273 -** Bar Design 155 +** Status Bar
274 The bar uses a performance-optimized approach with a modular block system: 156 The bar uses a performance-optimized approach with a modular block system:
275 -- Only redraws when invalidate() is called 157 +- Only redraws when invalidated
276 - Pre-calculates tag widths on creation 158 - Pre-calculates tag widths on creation
277 -- Uses X11 graphics context for efficient drawing 159 +- Blocks update independently based on their configured intervals
278 -- Click handling uses O(n) tag width lookup 160 +- Supports custom colors and underline indicators
279 -- Blocks are updated independently based on their interval 161 +- Easily extensible - add new block types in src/bar/blocks/
280 -- Each block can have custom colors and optional underline indicators 162 +
281 -- Blocks are defined in config.rs and can be: 163 +** Layout System
282 - - DateTime: Display formatted date/time 164 +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.
283 - - Battery: Show battery status with custom formats 165 +
284 - - Shell: Execute shell commands and display output 166 +* Development Roadmap
285 - - Static: Display fixed text 167 +** Current Focus
286 -- Blocks are easily hackable - add new block types in src/bar/blocks/ 168 +- Multi-monitor support
287 - 169 +- Additional layouts (monocle, floating)
288 -** Configuration Philosophy 170 +- Master area resizing
289 -Following dwm's approach: all configuration is in Rust source code. No runtime 171 +- Window swapping in layout
290 -config files. Edit config.rs and recompile. This ensures type safety and 172 +
291 -compile-time validation of all settings. 173 +** Future Enhancements
174 +- Per-window floating behavior
175 +- Per-program rules (auto-tag assignment, floating rules)
176 +- External bar support (polybar, lemonbar)
177 +- Scratchpad functionality
178 +- Window minimize/restore
292 179
293 * License 180 * License
294 -[[https://www.gnu.org/licenses/gpl-3.0.en.html][GPL]] 181 +[[https://www.gnu.org/licenses/gpl-3.0.en.html][GPL v3]]