tony / oxwm

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