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 2 #+STARTUP: overview
3 3
4 4 * Table of Contents :toc:
5 -- [[#oxwm--dwm-but-better-and-oxidized][OXWM — DWM but Better (and oxidized)]]
6 -- [[#project-structure][Project Structure]]
7 -- [[#event-flow][Event Flow]]
5 +- [[#oxwm][OXWM]]
6 +- [[#installation][Installation]]
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 12 - [[#key-bindings][Key Bindings]]
9 -- [[#-installation--running-with-nix-flakes][⚙ Installation — Running with Nix Flakes]]
10 -- [[#testing-xephyr-with-justfile][Testing Xephyr with Justfile]]
11 -- [[#current-status][Current Status]]
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]]
13 +- [[#features][Features]]
14 +- [[#testing-with-xephyr][Testing with Xephyr]]
15 +- [[#project-structure][Project Structure]]
24 16 - [[#architecture-notes][Architecture Notes]]
25 - - [[#tag-system][Tag System]]
26 - - [[#bar-design][Bar Design]]
27 - - [[#configuration-philosophy][Configuration Philosophy]]
17 +- [[#development-roadmap][Development Roadmap]]
28 18 - [[#license][License]]
29 19
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."*
20 +* OXWM
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."
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 31 #+begin_src sh
38 -src/
39 -├── main.rs
40 -│ └── main()
41 -│ └── Creates WindowManager and calls .run()
42 -│
43 -├── window_manager.rs [CORE - X11 event handling]
44 -│ ├── struct WindowManager
45 -│ │ ├── connection: RustConnection [X11 connection]
46 -│ │ ├── windows: Vec<Window> [All managed windows]
47 -│ │ ├── focused_window: Option<Window>
48 -│ │ ├── layout: Box<dyn Layout>
49 -│ │ ├── window_tags: HashMap<Window, TagMask>
50 -│ │ ├── selected_tags: TagMask
51 -│ │ └── bar: Bar [Status bar]
52 -│ │
53 -│ ├── new() [Initialize WM, grab root, restore tags, scan windows]
54 -│ ├── run() [Main event loop with block updates]
55 -│ ├── handle_event() [Route X11 events]
56 -│ │ ├── MapRequest → add window, apply layout, update bar, save tag
57 -│ │ ├── UnmapNotify → remove window, update bar
58 -│ │ ├── DestroyNotify → remove window, update bar
59 -│ │ ├── KeyPress → get action, handle it (includes Restart)
60 -│ │ ├── ButtonPress → handle bar clicks
61 -│ │ └── Expose → redraw bar
62 -│ ├── handle_key_action() [Execute keyboard actions]
63 -│ ├── get_saved_selected_tags() [Restore selected tags from _NET_CURRENT_DESKTOP]
64 -│ ├── save_selected_tags() [Persist selected tags to root window]
65 -│ ├── get_saved_tag() [Restore window tag from _NET_CLIENT_INFO]
66 -│ ├── save_client_tag() [Persist window tag to window property]
67 -│ ├── scan_existing_windows() [Manage windows on startup]
68 -│ ├── remove_window() [Remove from Vec, reapply layout]
69 -│ ├── set_focus() [Focus window, update visuals]
70 -│ ├── cycle_focus() [Move focus to next/prev window]
71 -│ ├── view_tag() [Switch to tag/workspace, update visibility]
72 -│ ├── move_to_tag() [Move window to tag]
73 -│ ├── update_bar() [Calculate occupied tags, redraw bar]
74 -│ ├── update_focus_visuals() [Set border colors]
75 -│ ├── update_window_visibility() [Map/unmap windows based on tags]
76 -│ └── apply_layout() [Position all windows below bar]
77 -│
78 -├── config.rs [CONFIGURATION - all settings here]
79 -│ ├── BORDER_WIDTH, BORDER_FOCUSED, BORDER_UNFOCUSED
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]
32 +git clone https://github.com/tonybanters/oxwm
33 +cd oxwm
34 +cargo build --release
35 +sudo cp target/release/oxwm /usr/local/bin/
36 +#+end_src
37 +
38 +Or use the justfile:
39 +#+begin_src sh
40 +just install
41 +#+end_src
42 +
43 +** Setting up OXWM
44 +Add the following to your =~/.xinitrc=:
45 +#+begin_src sh
46 +exec oxwm
47 +#+end_src
48 +
49 +Then start X with:
50 +#+begin_src sh
51 +startx
52 +#+end_src
53 +
54 +* Configuration
55 +OXWM follows the suckless philosophy: configuration is done by editing =src/config.rs= and recompiling.
56 +
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.
58 +
59 +To reset your config to defaults:
60 +#+begin_src sh
61 +just reset-config
62 +#+end_src
63 +
64 +Edit =src/config.rs= to customize:
65 +- Keybindings
66 +- Colors and appearance
67 +- Status bar blocks
68 +- Gaps and borders
69 +- Terminal and applications
70 +
71 +After making changes:
72 +#+begin_src sh
73 +just install
121 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
126 -2. handle_event() matches event type
127 -3. For KeyPress:
128 - - keyboard::handle_key_press() → KeyAction
129 - - handle_key_action() executes action
130 - - update_bar() if tags/windows changed
131 -4. For Map/Unmap:
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
78 +* Contributing
79 +When contributing to OXWM:
80 +
81 +1. Never commit your personal =src/config.rs= (it's gitignored)
82 +2. Only modify =src/default_config.rs= if adding new configuration options
83 +3. Test your changes with =just test= using Xephyr
84 +4. Document any new features or keybindings
139 85
140 86 * Key Bindings
87 +Default keybindings (customizable in config.rs):
141 88
142 89 | Binding | Action |
143 90 |-----------------+-------------------------|
@@ -149,146 +96,86 @@ src/
149 96 | Alt+1-9 | View tag 1-9 |
150 97 | Alt+Shift+1-9 | Move window to tag 1-9 |
151 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
155 -You can set up a reproducible development environment with Rust, Cargo, Xephyr, xterm, and
156 -just by using the flake.
118 +* Testing with Xephyr
119 +Test OXWM in a nested X server without affecting your current session:
157 120
158 121 #+begin_src sh
159 -git clone https://github.com/tonybanters/oxwm
160 -cd oxwm
161 -
162 -# enter the dev shell
163 -nix develop
164 -
165 -# build normally
166 -cargo build
122 +just test
167 123 #+end_src
168 124
169 -* Testing Xephyr with Justfile
170 -The =justfile= includes a =test= recipe that starts Xephyr on =:1=, launches
171 -test clients (xterm, xclock), and runs oxwm in the foreground.
125 +This starts Xephyr on display :1 and launches OXWM inside it.
172 126
127 +Or manually:
173 128 #+begin_src sh
174 -# inside nix develop
175 -just test
129 +Xephyr -screen 1280x800 :1 &
130 +DISPLAY=:1 cargo run
176 131 #+end_src
177 132
178 -This should open a new Xephyr window. oxwm will attach to it and log X11
179 -events in your host terminal. Clients like xterm/xclock will appear inside Xephyr.
180 -
181 -* Current Status
182 -** Working Features
183 -- ✓ X11 event handling and window management
184 -- ✓ Tag system (9 workspaces) with keyboard switching
185 -- ✓ Window focus cycling (Alt+J/K)
186 -- ✓ Tiling layout with border indicators
187 -- ✓ Status bar showing tags
188 - - Visual indicators: selected (white), occupied (gray line), empty (dim)
189 - - Click-to-switch tags
190 - - Performance-optimized redrawing
191 -- ✓ Basic keybindings (spawn, kill, focus, tags)
192 -- ✓ Configuration via Rust constants in config.rs
193 -- ✓ Hot reload functionality (Alt+Shift+R)
194 -- ✓ Persistent window tags across restarts
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)
133 +* Project Structure
134 +#+begin_src sh
135 +src/
136 +├── main.rs Entry point
137 +├── window_manager.rs Core X11 event handling and window management
138 +├── default_config.rs Default configuration (reference)
139 +├── config.rs User configuration (gitignored, auto-generated)
140 +├── bar/
141 +│ ├── bar.rs Status bar rendering with XFT
142 +│ ├── font.rs Font handling
143 +│ └── blocks/ Modular status bar widgets
144 +├── keyboard/
145 +│ ├── handlers.rs Keybinding actions
146 +│ └── keycodes.rs X11 keycode constants
147 +└── layout/
148 + └── tiling.rs Tiling layout algorithm
149 +#+end_src
264 150
265 151 * Architecture Notes
266 152 ** Tag System
267 -Tags are implemented as bitmasks (TagMask = u32), allowing windows to belong to
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).
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).
272 154
273 -** Bar Design
155 +** Status Bar
274 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 158 - Pre-calculates tag widths on creation
277 -- Uses X11 graphics context for efficient drawing
278 -- Click handling uses O(n) tag width lookup
279 -- Blocks are updated independently based on their interval
280 -- Each block can have custom colors and optional underline indicators
281 -- Blocks are defined in config.rs and can be:
282 - - DateTime: Display formatted date/time
283 - - Battery: Show battery status with custom formats
284 - - Shell: Execute shell commands and display output
285 - - Static: Display fixed text
286 -- Blocks are easily hackable - add new block types in src/bar/blocks/
287 -
288 -** Configuration Philosophy
289 -Following dwm's approach: all configuration is in Rust source code. No runtime
290 -config files. Edit config.rs and recompile. This ensures type safety and
291 -compile-time validation of all settings.
159 +- Blocks update independently based on their configured intervals
160 +- Supports custom colors and underline indicators
161 +- Easily extensible - add new block types in src/bar/blocks/
162 +
163 +** Layout System
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.
165 +
166 +* Development Roadmap
167 +** Current Focus
168 +- Multi-monitor support
169 +- Additional layouts (monocle, floating)
170 +- Master area resizing
171 +- Window swapping in layout
172 +
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 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]]