oxwm

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