tony / oxwm

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