tony / oxwm

Branch: 7efd8c0
Switch branches/tags
master
tonybtw fixed type mismatch a9b99bd 2025-10-11
194 lines · 6.5 KB Raw Blame History
1 pub mod bar;
2 pub mod keyboard;
3 pub mod layout;
4 pub mod window_manager;
5
6 pub mod prelude {
7 pub use crate::ColorScheme;
8 pub use crate::bar::{BlockCommand, BlockConfig};
9 pub use crate::keyboard::{Arg, KeyAction, handlers::Key, keycodes};
10 pub use x11rb::protocol::xproto::KeyButMask;
11 }
12
13 #[derive(Clone)]
14 pub struct Config {
15 // Appearance
16 pub border_width: u32,
17 pub border_focused: u32,
18 pub border_unfocused: u32,
19 pub font: String,
20
21 // Gaps
22 pub gaps_enabled: bool,
23 pub gap_inner_horizontal: u32,
24 pub gap_inner_vertical: u32,
25 pub gap_outer_horizontal: u32,
26 pub gap_outer_vertical: u32,
27
28 // Basics
29 pub terminal: String,
30 pub modkey: x11rb::protocol::xproto::KeyButMask,
31
32 // Tags
33 pub tags: Vec<String>,
34
35 // Keybindings
36 pub keybindings: Vec<crate::keyboard::handlers::Key>,
37
38 // Status bar
39 pub status_blocks: Vec<crate::bar::BlockConfig>,
40
41 // Bar color schemes
42 pub scheme_normal: ColorScheme,
43 pub scheme_occupied: ColorScheme,
44 pub scheme_selected: ColorScheme,
45 }
46
47 #[derive(Clone, Copy)]
48 pub struct ColorScheme {
49 pub foreground: u32,
50 pub background: u32,
51 pub underline: u32,
52 }
53
54 impl Default for Config {
55 fn default() -> Self {
56 use crate::keyboard::handlers::Key;
57 use crate::keyboard::{Arg, KeyAction, keycodes};
58 use x11rb::protocol::xproto::KeyButMask;
59
60 const MODKEY: KeyButMask = KeyButMask::MOD4;
61 const SHIFT: KeyButMask = KeyButMask::SHIFT;
62
63 const TERMINAL: &str = "st";
64
65 Self {
66 border_width: 2,
67 border_focused: 0x6dade3,
68 border_unfocused: 0xbbbbbb,
69 font: "monospace:size=12".to_string(),
70 gaps_enabled: false,
71 gap_inner_horizontal: 0,
72 gap_inner_vertical: 0,
73 gap_outer_horizontal: 0,
74 gap_outer_vertical: 0,
75 terminal: TERMINAL.to_string(),
76 modkey: MODKEY,
77 tags: vec!["1", "2", "3", "4", "5", "6", "7", "8", "9"]
78 .into_iter()
79 .map(String::from)
80 .collect(),
81 keybindings: vec![
82 Key::new(
83 &[MODKEY],
84 keycodes::RETURN,
85 KeyAction::Spawn,
86 Arg::Str(TERMINAL),
87 ),
88 Key::new(
89 &[MODKEY],
90 keycodes::D,
91 KeyAction::Spawn,
92 Arg::Array(&["sh", "-c", "dmenu_run"]),
93 ),
94 Key::new(&[MODKEY], keycodes::Q, KeyAction::KillClient, Arg::None),
95 Key::new(
96 &[MODKEY, SHIFT],
97 keycodes::F,
98 KeyAction::ToggleFullScreen,
99 Arg::None,
100 ),
101 Key::new(&[MODKEY], keycodes::A, KeyAction::ToggleGaps, Arg::None),
102 Key::new(&[MODKEY, SHIFT], keycodes::Q, KeyAction::Quit, Arg::None),
103 Key::new(&[MODKEY, SHIFT], keycodes::R, KeyAction::Restart, Arg::None),
104 Key::new(&[MODKEY], keycodes::J, KeyAction::FocusStack, Arg::Int(-1)),
105 Key::new(&[MODKEY], keycodes::K, KeyAction::FocusStack, Arg::Int(1)),
106 Key::new(&[MODKEY], keycodes::KEY_1, KeyAction::ViewTag, Arg::Int(0)),
107 Key::new(&[MODKEY], keycodes::KEY_2, KeyAction::ViewTag, Arg::Int(1)),
108 Key::new(&[MODKEY], keycodes::KEY_3, KeyAction::ViewTag, Arg::Int(2)),
109 Key::new(&[MODKEY], keycodes::KEY_4, KeyAction::ViewTag, Arg::Int(3)),
110 Key::new(&[MODKEY], keycodes::KEY_5, KeyAction::ViewTag, Arg::Int(4)),
111 Key::new(&[MODKEY], keycodes::KEY_6, KeyAction::ViewTag, Arg::Int(5)),
112 Key::new(&[MODKEY], keycodes::KEY_7, KeyAction::ViewTag, Arg::Int(6)),
113 Key::new(&[MODKEY], keycodes::KEY_8, KeyAction::ViewTag, Arg::Int(7)),
114 Key::new(&[MODKEY], keycodes::KEY_9, KeyAction::ViewTag, Arg::Int(8)),
115 Key::new(
116 &[MODKEY, SHIFT],
117 keycodes::KEY_1,
118 KeyAction::MoveToTag,
119 Arg::Int(0),
120 ),
121 Key::new(
122 &[MODKEY, SHIFT],
123 keycodes::KEY_2,
124 KeyAction::MoveToTag,
125 Arg::Int(1),
126 ),
127 Key::new(
128 &[MODKEY, SHIFT],
129 keycodes::KEY_3,
130 KeyAction::MoveToTag,
131 Arg::Int(2),
132 ),
133 Key::new(
134 &[MODKEY, SHIFT],
135 keycodes::KEY_4,
136 KeyAction::MoveToTag,
137 Arg::Int(3),
138 ),
139 Key::new(
140 &[MODKEY, SHIFT],
141 keycodes::KEY_5,
142 KeyAction::MoveToTag,
143 Arg::Int(4),
144 ),
145 Key::new(
146 &[MODKEY, SHIFT],
147 keycodes::KEY_6,
148 KeyAction::MoveToTag,
149 Arg::Int(5),
150 ),
151 Key::new(
152 &[MODKEY, SHIFT],
153 keycodes::KEY_7,
154 KeyAction::MoveToTag,
155 Arg::Int(6),
156 ),
157 Key::new(
158 &[MODKEY, SHIFT],
159 keycodes::KEY_8,
160 KeyAction::MoveToTag,
161 Arg::Int(7),
162 ),
163 Key::new(
164 &[MODKEY, SHIFT],
165 keycodes::KEY_9,
166 KeyAction::MoveToTag,
167 Arg::Int(8),
168 ),
169 ],
170 status_blocks: vec![crate::bar::BlockConfig {
171 format: " {}",
172 command: crate::bar::BlockCommand::DateTime("%a, %b %d - %-I:%M %P"),
173 interval_secs: 1,
174 color: 0x0db9d7,
175 underline: true,
176 }],
177 scheme_normal: ColorScheme {
178 foreground: 0xbbbbbb,
179 background: 0x1a1b26,
180 underline: 0x444444,
181 },
182 scheme_occupied: ColorScheme {
183 foreground: 0x0db9d7,
184 background: 0x1a1b26,
185 underline: 0x0db9d7,
186 },
187 scheme_selected: ColorScheme {
188 foreground: 0x0db9d7,
189 background: 0x1a1b26,
190 underline: 0xad8ee6,
191 },
192 }
193 }
194 }