tony / oxwm

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