| 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::KeyBinding, keysyms}; |
| 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::KeyBinding; |
| 70 | use crate::keyboard::{Arg, KeyAction, keysyms}; |
| 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 | KeyBinding::single_key( |
| 97 | vec![MODKEY], |
| 98 | keysyms::XK_RETURN, |
| 99 | KeyAction::Spawn, |
| 100 | Arg::Str(TERMINAL.to_string()), |
| 101 | ), |
| 102 | KeyBinding::single_key( |
| 103 | vec![MODKEY], |
| 104 | keysyms::XK_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 | KeyBinding::single_key(vec![MODKEY], keysyms::XK_Q, KeyAction::KillClient, Arg::None), |
| 113 | KeyBinding::single_key(vec![MODKEY], keysyms::XK_N, KeyAction::CycleLayout, Arg::None), |
| 114 | KeyBinding::single_key( |
| 115 | vec![MODKEY, SHIFT], |
| 116 | keysyms::XK_F, |
| 117 | KeyAction::ToggleFullScreen, |
| 118 | Arg::None, |
| 119 | ), |
| 120 | KeyBinding::single_key(vec![MODKEY], keysyms::XK_A, KeyAction::ToggleGaps, Arg::None), |
| 121 | KeyBinding::single_key(vec![MODKEY, SHIFT], keysyms::XK_Q, KeyAction::Quit, Arg::None), |
| 122 | KeyBinding::single_key( |
| 123 | vec![MODKEY, SHIFT], |
| 124 | keysyms::XK_R, |
| 125 | KeyAction::Restart, |
| 126 | Arg::None, |
| 127 | ), |
| 128 | KeyBinding::single_key( |
| 129 | vec![MODKEY], |
| 130 | keysyms::XK_F, |
| 131 | KeyAction::ToggleFloating, |
| 132 | Arg::None, |
| 133 | ), |
| 134 | KeyBinding::single_key( |
| 135 | vec![MODKEY], |
| 136 | keysyms::XK_J, |
| 137 | KeyAction::FocusStack, |
| 138 | Arg::Int(-1), |
| 139 | ), |
| 140 | KeyBinding::single_key( |
| 141 | vec![MODKEY], |
| 142 | keysyms::XK_K, |
| 143 | KeyAction::FocusStack, |
| 144 | Arg::Int(1), |
| 145 | ), |
| 146 | KeyBinding::single_key( |
| 147 | vec![MODKEY, SHIFT], |
| 148 | keysyms::XK_K, |
| 149 | KeyAction::ExchangeClient, |
| 150 | Arg::Int(0), // UP |
| 151 | ), |
| 152 | KeyBinding::single_key( |
| 153 | vec![MODKEY, SHIFT], |
| 154 | keysyms::XK_J, |
| 155 | KeyAction::ExchangeClient, |
| 156 | Arg::Int(1), // DOWN |
| 157 | ), |
| 158 | KeyBinding::single_key( |
| 159 | vec![MODKEY, SHIFT], |
| 160 | keysyms::XK_H, |
| 161 | KeyAction::ExchangeClient, |
| 162 | Arg::Int(2), // LEFT |
| 163 | ), |
| 164 | KeyBinding::single_key( |
| 165 | vec![MODKEY, SHIFT], |
| 166 | keysyms::XK_L, |
| 167 | KeyAction::ExchangeClient, |
| 168 | Arg::Int(3), // RIGHT |
| 169 | ), |
| 170 | KeyBinding::single_key( |
| 171 | vec![MODKEY], |
| 172 | keysyms::XK_1, |
| 173 | KeyAction::ViewTag, |
| 174 | Arg::Int(0), |
| 175 | ), |
| 176 | KeyBinding::single_key( |
| 177 | vec![MODKEY], |
| 178 | keysyms::XK_2, |
| 179 | KeyAction::ViewTag, |
| 180 | Arg::Int(1), |
| 181 | ), |
| 182 | KeyBinding::single_key( |
| 183 | vec![MODKEY], |
| 184 | keysyms::XK_3, |
| 185 | KeyAction::ViewTag, |
| 186 | Arg::Int(2), |
| 187 | ), |
| 188 | KeyBinding::single_key( |
| 189 | vec![MODKEY], |
| 190 | keysyms::XK_4, |
| 191 | KeyAction::ViewTag, |
| 192 | Arg::Int(3), |
| 193 | ), |
| 194 | KeyBinding::single_key( |
| 195 | vec![MODKEY], |
| 196 | keysyms::XK_5, |
| 197 | KeyAction::ViewTag, |
| 198 | Arg::Int(4), |
| 199 | ), |
| 200 | KeyBinding::single_key( |
| 201 | vec![MODKEY], |
| 202 | keysyms::XK_6, |
| 203 | KeyAction::ViewTag, |
| 204 | Arg::Int(5), |
| 205 | ), |
| 206 | KeyBinding::single_key( |
| 207 | vec![MODKEY], |
| 208 | keysyms::XK_7, |
| 209 | KeyAction::ViewTag, |
| 210 | Arg::Int(6), |
| 211 | ), |
| 212 | KeyBinding::single_key( |
| 213 | vec![MODKEY], |
| 214 | keysyms::XK_8, |
| 215 | KeyAction::ViewTag, |
| 216 | Arg::Int(7), |
| 217 | ), |
| 218 | KeyBinding::single_key( |
| 219 | vec![MODKEY], |
| 220 | keysyms::XK_9, |
| 221 | KeyAction::ViewTag, |
| 222 | Arg::Int(8), |
| 223 | ), |
| 224 | KeyBinding::single_key( |
| 225 | vec![MODKEY, SHIFT], |
| 226 | keysyms::XK_1, |
| 227 | KeyAction::MoveToTag, |
| 228 | Arg::Int(0), |
| 229 | ), |
| 230 | KeyBinding::single_key( |
| 231 | vec![MODKEY, SHIFT], |
| 232 | keysyms::XK_2, |
| 233 | KeyAction::MoveToTag, |
| 234 | Arg::Int(1), |
| 235 | ), |
| 236 | KeyBinding::single_key( |
| 237 | vec![MODKEY, SHIFT], |
| 238 | keysyms::XK_3, |
| 239 | KeyAction::MoveToTag, |
| 240 | Arg::Int(2), |
| 241 | ), |
| 242 | KeyBinding::single_key( |
| 243 | vec![MODKEY, SHIFT], |
| 244 | keysyms::XK_4, |
| 245 | KeyAction::MoveToTag, |
| 246 | Arg::Int(3), |
| 247 | ), |
| 248 | KeyBinding::single_key( |
| 249 | vec![MODKEY, SHIFT], |
| 250 | keysyms::XK_5, |
| 251 | KeyAction::MoveToTag, |
| 252 | Arg::Int(4), |
| 253 | ), |
| 254 | KeyBinding::single_key( |
| 255 | vec![MODKEY, SHIFT], |
| 256 | keysyms::XK_6, |
| 257 | KeyAction::MoveToTag, |
| 258 | Arg::Int(5), |
| 259 | ), |
| 260 | KeyBinding::single_key( |
| 261 | vec![MODKEY, SHIFT], |
| 262 | keysyms::XK_7, |
| 263 | KeyAction::MoveToTag, |
| 264 | Arg::Int(6), |
| 265 | ), |
| 266 | KeyBinding::single_key( |
| 267 | vec![MODKEY, SHIFT], |
| 268 | keysyms::XK_8, |
| 269 | KeyAction::MoveToTag, |
| 270 | Arg::Int(7), |
| 271 | ), |
| 272 | KeyBinding::single_key( |
| 273 | vec![MODKEY, SHIFT], |
| 274 | keysyms::XK_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 | } |