tony / oxwm

Branch: eb91466
Switch branches/tags
master
tonybtw Added support for multiple monitors using randr library and dwm.c logic. Applied bar updates for multi monitor support. 84c9fb0 2025-10-17
267 lines · 8.1 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(
103 vec![MODKEY, SHIFT],
104 keycodes::F,
105 KeyAction::ToggleFullScreen,
106 Arg::None,
107 ),
108 Key::new(vec![MODKEY], keycodes::A, KeyAction::ToggleGaps, Arg::None),
109 Key::new(vec![MODKEY, SHIFT], keycodes::Q, KeyAction::Quit, Arg::None),
110 Key::new(
111 vec![MODKEY, SHIFT],
112 keycodes::R,
113 KeyAction::Restart,
114 Arg::None,
115 ),
116 Key::new(
117 vec![MODKEY],
118 keycodes::F,
119 KeyAction::ToggleFloating,
120 Arg::None,
121 ),
122 Key::new(
123 vec![MODKEY],
124 keycodes::J,
125 KeyAction::FocusStack,
126 Arg::Int(-1),
127 ),
128 Key::new(
129 vec![MODKEY],
130 keycodes::K,
131 KeyAction::FocusStack,
132 Arg::Int(1),
133 ),
134 Key::new(
135 vec![MODKEY],
136 keycodes::KEY_1,
137 KeyAction::ViewTag,
138 Arg::Int(0),
139 ),
140 Key::new(
141 vec![MODKEY],
142 keycodes::KEY_2,
143 KeyAction::ViewTag,
144 Arg::Int(1),
145 ),
146 Key::new(
147 vec![MODKEY],
148 keycodes::KEY_3,
149 KeyAction::ViewTag,
150 Arg::Int(2),
151 ),
152 Key::new(
153 vec![MODKEY],
154 keycodes::KEY_4,
155 KeyAction::ViewTag,
156 Arg::Int(3),
157 ),
158 Key::new(
159 vec![MODKEY],
160 keycodes::KEY_5,
161 KeyAction::ViewTag,
162 Arg::Int(4),
163 ),
164 Key::new(
165 vec![MODKEY],
166 keycodes::KEY_6,
167 KeyAction::ViewTag,
168 Arg::Int(5),
169 ),
170 Key::new(
171 vec![MODKEY],
172 keycodes::KEY_7,
173 KeyAction::ViewTag,
174 Arg::Int(6),
175 ),
176 Key::new(
177 vec![MODKEY],
178 keycodes::KEY_8,
179 KeyAction::ViewTag,
180 Arg::Int(7),
181 ),
182 Key::new(
183 vec![MODKEY],
184 keycodes::KEY_9,
185 KeyAction::ViewTag,
186 Arg::Int(8),
187 ),
188 Key::new(
189 vec![MODKEY, SHIFT],
190 keycodes::KEY_1,
191 KeyAction::MoveToTag,
192 Arg::Int(0),
193 ),
194 Key::new(
195 vec![MODKEY, SHIFT],
196 keycodes::KEY_2,
197 KeyAction::MoveToTag,
198 Arg::Int(1),
199 ),
200 Key::new(
201 vec![MODKEY, SHIFT],
202 keycodes::KEY_3,
203 KeyAction::MoveToTag,
204 Arg::Int(2),
205 ),
206 Key::new(
207 vec![MODKEY, SHIFT],
208 keycodes::KEY_4,
209 KeyAction::MoveToTag,
210 Arg::Int(3),
211 ),
212 Key::new(
213 vec![MODKEY, SHIFT],
214 keycodes::KEY_5,
215 KeyAction::MoveToTag,
216 Arg::Int(4),
217 ),
218 Key::new(
219 vec![MODKEY, SHIFT],
220 keycodes::KEY_6,
221 KeyAction::MoveToTag,
222 Arg::Int(5),
223 ),
224 Key::new(
225 vec![MODKEY, SHIFT],
226 keycodes::KEY_7,
227 KeyAction::MoveToTag,
228 Arg::Int(6),
229 ),
230 Key::new(
231 vec![MODKEY, SHIFT],
232 keycodes::KEY_8,
233 KeyAction::MoveToTag,
234 Arg::Int(7),
235 ),
236 Key::new(
237 vec![MODKEY, SHIFT],
238 keycodes::KEY_9,
239 KeyAction::MoveToTag,
240 Arg::Int(8),
241 ),
242 ],
243 status_blocks: vec![crate::bar::BlockConfig {
244 format: "{}".to_string(),
245 command: crate::bar::BlockCommand::DateTime("%a, %b %d - %-I:%M %P".to_string()),
246 interval_secs: 1,
247 color: 0x0db9d7,
248 underline: true,
249 }],
250 scheme_normal: ColorScheme {
251 foreground: 0xbbbbbb,
252 background: 0x1a1b26,
253 underline: 0x444444,
254 },
255 scheme_occupied: ColorScheme {
256 foreground: 0x0db9d7,
257 background: 0x1a1b26,
258 underline: 0x0db9d7,
259 },
260 scheme_selected: ColorScheme {
261 foreground: 0x0db9d7,
262 background: 0x1a1b26,
263 underline: 0xad8ee6,
264 },
265 }
266 }
267 }