oxwm

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