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