tony / oxwm

Branch: 5099cb0
Switch branches/tags
master
tonybanters refactored to allow ron file, and not have to deal with compiling or initting. added ron parser 5099cb0 2025-10-14
196 lines · 6.5 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 &[MODKEY],
86 keycodes::RETURN,
87 KeyAction::Spawn,
88 Arg::Str(TERMINAL),
89 ),
90 Key::new(
91 &[MODKEY],
92 keycodes::D,
93 KeyAction::Spawn,
94 Arg::Array(&["sh", "-c", "dmenu_run"]),
95 ),
96 Key::new(&[MODKEY], keycodes::Q, KeyAction::KillClient, Arg::None),
97 Key::new(
98 &[MODKEY, SHIFT],
99 keycodes::F,
100 KeyAction::ToggleFullScreen,
101 Arg::None,
102 ),
103 Key::new(&[MODKEY], keycodes::A, KeyAction::ToggleGaps, Arg::None),
104 Key::new(&[MODKEY, SHIFT], keycodes::Q, KeyAction::Quit, Arg::None),
105 Key::new(&[MODKEY, SHIFT], keycodes::R, KeyAction::Restart, Arg::None),
106 Key::new(&[MODKEY], keycodes::J, KeyAction::FocusStack, Arg::Int(-1)),
107 Key::new(&[MODKEY], keycodes::K, KeyAction::FocusStack, Arg::Int(1)),
108 Key::new(&[MODKEY], keycodes::KEY_1, KeyAction::ViewTag, Arg::Int(0)),
109 Key::new(&[MODKEY], keycodes::KEY_2, KeyAction::ViewTag, Arg::Int(1)),
110 Key::new(&[MODKEY], keycodes::KEY_3, KeyAction::ViewTag, Arg::Int(2)),
111 Key::new(&[MODKEY], keycodes::KEY_4, KeyAction::ViewTag, Arg::Int(3)),
112 Key::new(&[MODKEY], keycodes::KEY_5, KeyAction::ViewTag, Arg::Int(4)),
113 Key::new(&[MODKEY], keycodes::KEY_6, KeyAction::ViewTag, Arg::Int(5)),
114 Key::new(&[MODKEY], keycodes::KEY_7, KeyAction::ViewTag, Arg::Int(6)),
115 Key::new(&[MODKEY], keycodes::KEY_8, KeyAction::ViewTag, Arg::Int(7)),
116 Key::new(&[MODKEY], keycodes::KEY_9, KeyAction::ViewTag, Arg::Int(8)),
117 Key::new(
118 &[MODKEY, SHIFT],
119 keycodes::KEY_1,
120 KeyAction::MoveToTag,
121 Arg::Int(0),
122 ),
123 Key::new(
124 &[MODKEY, SHIFT],
125 keycodes::KEY_2,
126 KeyAction::MoveToTag,
127 Arg::Int(1),
128 ),
129 Key::new(
130 &[MODKEY, SHIFT],
131 keycodes::KEY_3,
132 KeyAction::MoveToTag,
133 Arg::Int(2),
134 ),
135 Key::new(
136 &[MODKEY, SHIFT],
137 keycodes::KEY_4,
138 KeyAction::MoveToTag,
139 Arg::Int(3),
140 ),
141 Key::new(
142 &[MODKEY, SHIFT],
143 keycodes::KEY_5,
144 KeyAction::MoveToTag,
145 Arg::Int(4),
146 ),
147 Key::new(
148 &[MODKEY, SHIFT],
149 keycodes::KEY_6,
150 KeyAction::MoveToTag,
151 Arg::Int(5),
152 ),
153 Key::new(
154 &[MODKEY, SHIFT],
155 keycodes::KEY_7,
156 KeyAction::MoveToTag,
157 Arg::Int(6),
158 ),
159 Key::new(
160 &[MODKEY, SHIFT],
161 keycodes::KEY_8,
162 KeyAction::MoveToTag,
163 Arg::Int(7),
164 ),
165 Key::new(
166 &[MODKEY, SHIFT],
167 keycodes::KEY_9,
168 KeyAction::MoveToTag,
169 Arg::Int(8),
170 ),
171 ],
172 status_blocks: vec![crate::bar::BlockConfig {
173 format: " {}",
174 command: crate::bar::BlockCommand::DateTime("%a, %b %d - %-I:%M %P"),
175 interval_secs: 1,
176 color: 0x0db9d7,
177 underline: true,
178 }],
179 scheme_normal: ColorScheme {
180 foreground: 0xbbbbbb,
181 background: 0x1a1b26,
182 underline: 0x444444,
183 },
184 scheme_occupied: ColorScheme {
185 foreground: 0x0db9d7,
186 background: 0x1a1b26,
187 underline: 0x0db9d7,
188 },
189 scheme_selected: ColorScheme {
190 foreground: 0x0db9d7,
191 background: 0x1a1b26,
192 underline: 0xad8ee6,
193 },
194 }
195 }
196 }