tony / oxwm

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