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