oxwm

https://git.tonybtw.com/oxwm.git git://git.tonybtw.com/oxwm.git
10,084 bytes raw
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 overlay;
8
pub mod tab_bar;
9
pub mod window_manager;
10
11
pub mod prelude {
12
    pub use crate::ColorScheme;
13
    pub use crate::LayoutSymbolOverride;
14
    pub use crate::bar::{BlockCommand, BlockConfig};
15
    pub use crate::keyboard::{Arg, KeyAction, handlers::KeyBinding, keysyms};
16
    pub use x11rb::protocol::xproto::KeyButMask;
17
}
18
19
#[derive(Clone)]
20
pub struct LayoutSymbolOverride {
21
    pub name: String,
22
    pub symbol: String,
23
}
24
25
#[derive(Clone)]
26
pub struct Config {
27
    // Appearance
28
    pub border_width: u32,
29
    pub border_focused: u32,
30
    pub border_unfocused: u32,
31
    pub font: String,
32
33
    // Gaps
34
    pub gaps_enabled: bool,
35
    pub gap_inner_horizontal: u32,
36
    pub gap_inner_vertical: u32,
37
    pub gap_outer_horizontal: u32,
38
    pub gap_outer_vertical: u32,
39
40
    // Basics
41
    pub terminal: String,
42
    pub modkey: x11rb::protocol::xproto::KeyButMask,
43
44
    // Tags
45
    pub tags: Vec<String>,
46
47
    // Layout symbol overrides
48
    pub layout_symbols: Vec<LayoutSymbolOverride>,
49
50
    // Keybindings
51
    pub keybindings: Vec<crate::keyboard::handlers::Key>,
52
53
    // Status bar
54
    pub status_blocks: Vec<crate::bar::BlockConfig>,
55
56
    // Bar color schemes
57
    pub scheme_normal: ColorScheme,
58
    pub scheme_occupied: ColorScheme,
59
    pub scheme_selected: ColorScheme,
60
61
    // Autostart commands
62
    pub autostart: Vec<String>,
63
}
64
65
#[derive(Clone, Copy)]
66
pub struct ColorScheme {
67
    pub foreground: u32,
68
    pub background: u32,
69
    pub underline: u32,
70
}
71
72
impl Default for Config {
73
    fn default() -> Self {
74
        use crate::keyboard::handlers::KeyBinding;
75
        use crate::keyboard::{Arg, KeyAction, keysyms};
76
        use x11rb::protocol::xproto::KeyButMask;
77
78
        const MODKEY: KeyButMask = KeyButMask::MOD4;
79
        const SHIFT: KeyButMask = KeyButMask::SHIFT;
80
81
        const TERMINAL: &str = "st";
82
83
        Self {
84
            border_width: 2,
85
            border_focused: 0x6dade3,
86
            border_unfocused: 0xbbbbbb,
87
            font: "monospace:size=10".to_string(),
88
            gaps_enabled: false,
89
            gap_inner_horizontal: 0,
90
            gap_inner_vertical: 0,
91
            gap_outer_horizontal: 0,
92
            gap_outer_vertical: 0,
93
            terminal: TERMINAL.to_string(),
94
            modkey: MODKEY,
95
            tags: vec!["1", "2", "3", "4", "5", "6", "7", "8", "9"]
96
                .into_iter()
97
                .map(String::from)
98
                .collect(),
99
            layout_symbols: vec![],
100
            keybindings: vec![
101
                KeyBinding::single_key(
102
                    vec![MODKEY],
103
                    keysyms::XK_RETURN,
104
                    KeyAction::Spawn,
105
                    Arg::Str(TERMINAL.to_string()),
106
                ),
107
                KeyBinding::single_key(
108
                    vec![MODKEY],
109
                    keysyms::XK_D,
110
                    KeyAction::Spawn,
111
                    Arg::Array(vec![
112
                        "sh".to_string(),
113
                        "-c".to_string(),
114
                        "dmenu_run -l 10".to_string(),
115
                    ]),
116
                ),
117
                KeyBinding::single_key(vec![MODKEY], keysyms::XK_Q, KeyAction::KillClient, Arg::None),
118
                KeyBinding::single_key(vec![MODKEY], keysyms::XK_N, KeyAction::CycleLayout, Arg::None),
119
                KeyBinding::single_key(
120
                    vec![MODKEY, SHIFT],
121
                    keysyms::XK_F,
122
                    KeyAction::ToggleFullScreen,
123
                    Arg::None,
124
                ),
125
                KeyBinding::single_key(vec![MODKEY], keysyms::XK_A, KeyAction::ToggleGaps, Arg::None),
126
                KeyBinding::single_key(vec![MODKEY, SHIFT], keysyms::XK_Q, KeyAction::Quit, Arg::None),
127
                KeyBinding::single_key(
128
                    vec![MODKEY, SHIFT],
129
                    keysyms::XK_R,
130
                    KeyAction::Restart,
131
                    Arg::None,
132
                ),
133
                KeyBinding::single_key(
134
                    vec![MODKEY],
135
                    keysyms::XK_F,
136
                    KeyAction::ToggleFloating,
137
                    Arg::None,
138
                ),
139
                KeyBinding::single_key(
140
                    vec![MODKEY],
141
                    keysyms::XK_J,
142
                    KeyAction::FocusStack,
143
                    Arg::Int(-1),
144
                ),
145
                KeyBinding::single_key(
146
                    vec![MODKEY],
147
                    keysyms::XK_K,
148
                    KeyAction::FocusStack,
149
                    Arg::Int(1),
150
                ),
151
                KeyBinding::single_key(
152
                    vec![MODKEY, SHIFT],
153
                    keysyms::XK_K,
154
                    KeyAction::ExchangeClient,
155
                    Arg::Int(0), // UP
156
                ),
157
                KeyBinding::single_key(
158
                    vec![MODKEY, SHIFT],
159
                    keysyms::XK_J,
160
                    KeyAction::ExchangeClient,
161
                    Arg::Int(1), // DOWN
162
                ),
163
                KeyBinding::single_key(
164
                    vec![MODKEY, SHIFT],
165
                    keysyms::XK_H,
166
                    KeyAction::ExchangeClient,
167
                    Arg::Int(2), // LEFT
168
                ),
169
                KeyBinding::single_key(
170
                    vec![MODKEY, SHIFT],
171
                    keysyms::XK_L,
172
                    KeyAction::ExchangeClient,
173
                    Arg::Int(3), // RIGHT
174
                ),
175
                KeyBinding::single_key(
176
                    vec![MODKEY],
177
                    keysyms::XK_1,
178
                    KeyAction::ViewTag,
179
                    Arg::Int(0),
180
                ),
181
                KeyBinding::single_key(
182
                    vec![MODKEY],
183
                    keysyms::XK_2,
184
                    KeyAction::ViewTag,
185
                    Arg::Int(1),
186
                ),
187
                KeyBinding::single_key(
188
                    vec![MODKEY],
189
                    keysyms::XK_3,
190
                    KeyAction::ViewTag,
191
                    Arg::Int(2),
192
                ),
193
                KeyBinding::single_key(
194
                    vec![MODKEY],
195
                    keysyms::XK_4,
196
                    KeyAction::ViewTag,
197
                    Arg::Int(3),
198
                ),
199
                KeyBinding::single_key(
200
                    vec![MODKEY],
201
                    keysyms::XK_5,
202
                    KeyAction::ViewTag,
203
                    Arg::Int(4),
204
                ),
205
                KeyBinding::single_key(
206
                    vec![MODKEY],
207
                    keysyms::XK_6,
208
                    KeyAction::ViewTag,
209
                    Arg::Int(5),
210
                ),
211
                KeyBinding::single_key(
212
                    vec![MODKEY],
213
                    keysyms::XK_7,
214
                    KeyAction::ViewTag,
215
                    Arg::Int(6),
216
                ),
217
                KeyBinding::single_key(
218
                    vec![MODKEY],
219
                    keysyms::XK_8,
220
                    KeyAction::ViewTag,
221
                    Arg::Int(7),
222
                ),
223
                KeyBinding::single_key(
224
                    vec![MODKEY],
225
                    keysyms::XK_9,
226
                    KeyAction::ViewTag,
227
                    Arg::Int(8),
228
                ),
229
                KeyBinding::single_key(
230
                    vec![MODKEY, SHIFT],
231
                    keysyms::XK_1,
232
                    KeyAction::MoveToTag,
233
                    Arg::Int(0),
234
                ),
235
                KeyBinding::single_key(
236
                    vec![MODKEY, SHIFT],
237
                    keysyms::XK_2,
238
                    KeyAction::MoveToTag,
239
                    Arg::Int(1),
240
                ),
241
                KeyBinding::single_key(
242
                    vec![MODKEY, SHIFT],
243
                    keysyms::XK_3,
244
                    KeyAction::MoveToTag,
245
                    Arg::Int(2),
246
                ),
247
                KeyBinding::single_key(
248
                    vec![MODKEY, SHIFT],
249
                    keysyms::XK_4,
250
                    KeyAction::MoveToTag,
251
                    Arg::Int(3),
252
                ),
253
                KeyBinding::single_key(
254
                    vec![MODKEY, SHIFT],
255
                    keysyms::XK_5,
256
                    KeyAction::MoveToTag,
257
                    Arg::Int(4),
258
                ),
259
                KeyBinding::single_key(
260
                    vec![MODKEY, SHIFT],
261
                    keysyms::XK_6,
262
                    KeyAction::MoveToTag,
263
                    Arg::Int(5),
264
                ),
265
                KeyBinding::single_key(
266
                    vec![MODKEY, SHIFT],
267
                    keysyms::XK_7,
268
                    KeyAction::MoveToTag,
269
                    Arg::Int(6),
270
                ),
271
                KeyBinding::single_key(
272
                    vec![MODKEY, SHIFT],
273
                    keysyms::XK_8,
274
                    KeyAction::MoveToTag,
275
                    Arg::Int(7),
276
                ),
277
                KeyBinding::single_key(
278
                    vec![MODKEY, SHIFT],
279
                    keysyms::XK_9,
280
                    KeyAction::MoveToTag,
281
                    Arg::Int(8),
282
                ),
283
            ],
284
            status_blocks: vec![crate::bar::BlockConfig {
285
                format: "{}".to_string(),
286
                command: crate::bar::BlockCommand::DateTime("%a, %b %d - %-I:%M %P".to_string()),
287
                interval_secs: 1,
288
                color: 0x0db9d7,
289
                underline: true,
290
            }],
291
            scheme_normal: ColorScheme {
292
                foreground: 0xbbbbbb,
293
                background: 0x1a1b26,
294
                underline: 0x444444,
295
            },
296
            scheme_occupied: ColorScheme {
297
                foreground: 0x0db9d7,
298
                background: 0x1a1b26,
299
                underline: 0x0db9d7,
300
            },
301
            scheme_selected: ColorScheme {
302
                foreground: 0x0db9d7,
303
                background: 0x1a1b26,
304
                underline: 0xad8ee6,
305
            },
306
            autostart: vec![],
307
        }
308
    }
309
}