tony / oxwm

Branch: a4a6486
Switch branches/tags
master
tonybtw Phase 1 and 2 of dwm conversion complete. a4a6486 2025-11-30
310 lines · 9.9 KB Raw Blame History
1 pub mod bar;
2 pub mod client;
3 pub mod config;
4 pub mod errors;
5 pub mod keyboard;
6 pub mod layout;
7 pub mod monitor;
8 pub mod overlay;
9 pub mod tab_bar;
10 pub mod window_manager;
11
12 pub mod prelude {
13 pub use crate::ColorScheme;
14 pub use crate::LayoutSymbolOverride;
15 pub use crate::bar::{BlockCommand, BlockConfig};
16 pub use crate::keyboard::{Arg, KeyAction, handlers::KeyBinding, keysyms};
17 pub use x11rb::protocol::xproto::KeyButMask;
18 }
19
20 #[derive(Clone)]
21 pub struct LayoutSymbolOverride {
22 pub name: String,
23 pub symbol: String,
24 }
25
26 #[derive(Clone)]
27 pub struct Config {
28 // Appearance
29 pub border_width: u32,
30 pub border_focused: u32,
31 pub border_unfocused: u32,
32 pub font: String,
33
34 // Gaps
35 pub gaps_enabled: bool,
36 pub gap_inner_horizontal: u32,
37 pub gap_inner_vertical: u32,
38 pub gap_outer_horizontal: u32,
39 pub gap_outer_vertical: u32,
40
41 // Basics
42 pub terminal: String,
43 pub modkey: x11rb::protocol::xproto::KeyButMask,
44
45 // Tags
46 pub tags: Vec<String>,
47
48 // Layout symbol overrides
49 pub layout_symbols: Vec<LayoutSymbolOverride>,
50
51 // Keybindings
52 pub keybindings: Vec<crate::keyboard::handlers::Key>,
53
54 // Status bar
55 pub status_blocks: Vec<crate::bar::BlockConfig>,
56
57 // Bar color schemes
58 pub scheme_normal: ColorScheme,
59 pub scheme_occupied: ColorScheme,
60 pub scheme_selected: ColorScheme,
61
62 // Autostart commands
63 pub autostart: Vec<String>,
64 }
65
66 #[derive(Clone, Copy)]
67 pub struct ColorScheme {
68 pub foreground: u32,
69 pub background: u32,
70 pub underline: u32,
71 }
72
73 impl Default for Config {
74 fn default() -> Self {
75 use crate::keyboard::handlers::KeyBinding;
76 use crate::keyboard::{Arg, KeyAction, keysyms};
77 use x11rb::protocol::xproto::KeyButMask;
78
79 const MODKEY: KeyButMask = KeyButMask::MOD4;
80 const SHIFT: KeyButMask = KeyButMask::SHIFT;
81
82 const TERMINAL: &str = "st";
83
84 Self {
85 border_width: 2,
86 border_focused: 0x6dade3,
87 border_unfocused: 0xbbbbbb,
88 font: "monospace:size=10".to_string(),
89 gaps_enabled: false,
90 gap_inner_horizontal: 0,
91 gap_inner_vertical: 0,
92 gap_outer_horizontal: 0,
93 gap_outer_vertical: 0,
94 terminal: TERMINAL.to_string(),
95 modkey: MODKEY,
96 tags: vec!["1", "2", "3", "4", "5", "6", "7", "8", "9"]
97 .into_iter()
98 .map(String::from)
99 .collect(),
100 layout_symbols: vec![],
101 keybindings: vec![
102 KeyBinding::single_key(
103 vec![MODKEY],
104 keysyms::XK_RETURN,
105 KeyAction::Spawn,
106 Arg::Str(TERMINAL.to_string()),
107 ),
108 KeyBinding::single_key(
109 vec![MODKEY],
110 keysyms::XK_D,
111 KeyAction::Spawn,
112 Arg::Array(vec![
113 "sh".to_string(),
114 "-c".to_string(),
115 "dmenu_run -l 10".to_string(),
116 ]),
117 ),
118 KeyBinding::single_key(vec![MODKEY], keysyms::XK_Q, KeyAction::KillClient, Arg::None),
119 KeyBinding::single_key(vec![MODKEY], keysyms::XK_N, KeyAction::CycleLayout, Arg::None),
120 KeyBinding::single_key(
121 vec![MODKEY, SHIFT],
122 keysyms::XK_F,
123 KeyAction::ToggleFullScreen,
124 Arg::None,
125 ),
126 KeyBinding::single_key(vec![MODKEY], keysyms::XK_A, KeyAction::ToggleGaps, Arg::None),
127 KeyBinding::single_key(vec![MODKEY, SHIFT], keysyms::XK_Q, KeyAction::Quit, Arg::None),
128 KeyBinding::single_key(
129 vec![MODKEY, SHIFT],
130 keysyms::XK_R,
131 KeyAction::Restart,
132 Arg::None,
133 ),
134 KeyBinding::single_key(
135 vec![MODKEY],
136 keysyms::XK_F,
137 KeyAction::ToggleFloating,
138 Arg::None,
139 ),
140 KeyBinding::single_key(
141 vec![MODKEY],
142 keysyms::XK_J,
143 KeyAction::FocusStack,
144 Arg::Int(-1),
145 ),
146 KeyBinding::single_key(
147 vec![MODKEY],
148 keysyms::XK_K,
149 KeyAction::FocusStack,
150 Arg::Int(1),
151 ),
152 KeyBinding::single_key(
153 vec![MODKEY, SHIFT],
154 keysyms::XK_K,
155 KeyAction::ExchangeClient,
156 Arg::Int(0), // UP
157 ),
158 KeyBinding::single_key(
159 vec![MODKEY, SHIFT],
160 keysyms::XK_J,
161 KeyAction::ExchangeClient,
162 Arg::Int(1), // DOWN
163 ),
164 KeyBinding::single_key(
165 vec![MODKEY, SHIFT],
166 keysyms::XK_H,
167 KeyAction::ExchangeClient,
168 Arg::Int(2), // LEFT
169 ),
170 KeyBinding::single_key(
171 vec![MODKEY, SHIFT],
172 keysyms::XK_L,
173 KeyAction::ExchangeClient,
174 Arg::Int(3), // RIGHT
175 ),
176 KeyBinding::single_key(
177 vec![MODKEY],
178 keysyms::XK_1,
179 KeyAction::ViewTag,
180 Arg::Int(0),
181 ),
182 KeyBinding::single_key(
183 vec![MODKEY],
184 keysyms::XK_2,
185 KeyAction::ViewTag,
186 Arg::Int(1),
187 ),
188 KeyBinding::single_key(
189 vec![MODKEY],
190 keysyms::XK_3,
191 KeyAction::ViewTag,
192 Arg::Int(2),
193 ),
194 KeyBinding::single_key(
195 vec![MODKEY],
196 keysyms::XK_4,
197 KeyAction::ViewTag,
198 Arg::Int(3),
199 ),
200 KeyBinding::single_key(
201 vec![MODKEY],
202 keysyms::XK_5,
203 KeyAction::ViewTag,
204 Arg::Int(4),
205 ),
206 KeyBinding::single_key(
207 vec![MODKEY],
208 keysyms::XK_6,
209 KeyAction::ViewTag,
210 Arg::Int(5),
211 ),
212 KeyBinding::single_key(
213 vec![MODKEY],
214 keysyms::XK_7,
215 KeyAction::ViewTag,
216 Arg::Int(6),
217 ),
218 KeyBinding::single_key(
219 vec![MODKEY],
220 keysyms::XK_8,
221 KeyAction::ViewTag,
222 Arg::Int(7),
223 ),
224 KeyBinding::single_key(
225 vec![MODKEY],
226 keysyms::XK_9,
227 KeyAction::ViewTag,
228 Arg::Int(8),
229 ),
230 KeyBinding::single_key(
231 vec![MODKEY, SHIFT],
232 keysyms::XK_1,
233 KeyAction::MoveToTag,
234 Arg::Int(0),
235 ),
236 KeyBinding::single_key(
237 vec![MODKEY, SHIFT],
238 keysyms::XK_2,
239 KeyAction::MoveToTag,
240 Arg::Int(1),
241 ),
242 KeyBinding::single_key(
243 vec![MODKEY, SHIFT],
244 keysyms::XK_3,
245 KeyAction::MoveToTag,
246 Arg::Int(2),
247 ),
248 KeyBinding::single_key(
249 vec![MODKEY, SHIFT],
250 keysyms::XK_4,
251 KeyAction::MoveToTag,
252 Arg::Int(3),
253 ),
254 KeyBinding::single_key(
255 vec![MODKEY, SHIFT],
256 keysyms::XK_5,
257 KeyAction::MoveToTag,
258 Arg::Int(4),
259 ),
260 KeyBinding::single_key(
261 vec![MODKEY, SHIFT],
262 keysyms::XK_6,
263 KeyAction::MoveToTag,
264 Arg::Int(5),
265 ),
266 KeyBinding::single_key(
267 vec![MODKEY, SHIFT],
268 keysyms::XK_7,
269 KeyAction::MoveToTag,
270 Arg::Int(6),
271 ),
272 KeyBinding::single_key(
273 vec![MODKEY, SHIFT],
274 keysyms::XK_8,
275 KeyAction::MoveToTag,
276 Arg::Int(7),
277 ),
278 KeyBinding::single_key(
279 vec![MODKEY, SHIFT],
280 keysyms::XK_9,
281 KeyAction::MoveToTag,
282 Arg::Int(8),
283 ),
284 ],
285 status_blocks: vec![crate::bar::BlockConfig {
286 format: "{}".to_string(),
287 command: crate::bar::BlockCommand::DateTime("%a, %b %d - %-I:%M %P".to_string()),
288 interval_secs: 1,
289 color: 0x0db9d7,
290 underline: true,
291 }],
292 scheme_normal: ColorScheme {
293 foreground: 0xbbbbbb,
294 background: 0x1a1b26,
295 underline: 0x444444,
296 },
297 scheme_occupied: ColorScheme {
298 foreground: 0x0db9d7,
299 background: 0x1a1b26,
300 underline: 0x0db9d7,
301 },
302 scheme_selected: ColorScheme {
303 foreground: 0x0db9d7,
304 background: 0x1a1b26,
305 underline: 0xad8ee6,
306 },
307 autostart: vec![],
308 }
309 }
310 }