fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 1 | //! The TOML config. Parsing and validation only, the compositor applies it. |
57f44a63d99f | atagen | 2026-10-16 05:34 UTC | 2 | |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 3 | use monolith_ipc::Command; |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 4 | use regex::Regex; |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 5 | use serde::Deserialize; |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 6 | use std::collections::BTreeMap; |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 7 | use std::fmt; |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 8 | use std::path::{Path, PathBuf}; |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 9 | |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 10 | pub const DEFAULT: &str = include_str!("../default.toml"); |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 11 | |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 12 | #[derive(Debug, Clone)] |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 13 | pub struct Config { |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 14 | pub general: General, |
8e6f96f0a32d | atagen | 2026-10-16 22:17 UTC | 15 | pub output: Outputs, |
7ce6ae4e5a85 | atagen | 2026-10-16 12:16 UTC | 16 | pub decoration: Decoration, |
2af1d8c55876 | atagen | 2026-10-16 11:05 UTC | 17 | pub animation: Animation, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 18 | pub keyboard: Keyboard, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 19 | pub binds: Vec<Bind>, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 20 | pub rules: Vec<Rule>, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 21 | pub startup: Vec<Vec<String>>, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 22 | } |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 23 | |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 24 | #[derive(Deserialize, Debug, Clone, PartialEq)] |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 25 | #[serde(default, deny_unknown_fields)] |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 26 | pub struct General { |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 27 | /// What `Mod` means in binds. |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 28 | #[serde(rename = "mod")] |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 29 | pub mod_key: Modifier, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 30 | pub gaps: Gaps, |
4444c779eb48 | atagen | 2026-10-16 12:07 UTC | 31 | /// What a window move does when it meets a neighbour. |
4444c779eb48 | atagen | 2026-10-16 12:07 UTC | 32 | #[serde(rename = "move")] |
4444c779eb48 | atagen | 2026-10-16 12:07 UTC | 33 | pub move_mode: MoveMode, |
24fca1aad608 | atagen | 2026-10-17 09:56 UTC | 34 | pub focus_follows_mouse: bool, |
24fca1aad608 | atagen | 2026-10-17 09:56 UTC | 35 | pub mouse_follows_focus: bool, |
4444c779eb48 | atagen | 2026-10-16 12:07 UTC | 36 | } |
4444c779eb48 | atagen | 2026-10-16 12:07 UTC | 37 | |
4444c779eb48 | atagen | 2026-10-16 12:07 UTC | 38 | #[derive(Deserialize, Debug, Clone, Copy, PartialEq, Eq, Default)] |
4444c779eb48 | atagen | 2026-10-16 12:07 UTC | 39 | #[serde(rename_all = "lowercase")] |
4444c779eb48 | atagen | 2026-10-16 12:07 UTC | 40 | pub enum MoveMode { |
4444c779eb48 | atagen | 2026-10-16 12:07 UTC | 41 | /// Trade places with it. |
4444c779eb48 | atagen | 2026-10-16 12:07 UTC | 42 | #[default] |
4444c779eb48 | atagen | 2026-10-16 12:07 UTC | 43 | Swap, |
4444c779eb48 | atagen | 2026-10-16 12:07 UTC | 44 | /// Join its lane, stacking with it if it is alone. |
4444c779eb48 | atagen | 2026-10-16 12:07 UTC | 45 | Merge, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 46 | } |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 47 | |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 48 | impl Default for General { |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 49 | fn default() -> Self { |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 50 | Self { |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 51 | mod_key: Modifier::Super, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 52 | gaps: Gaps::default(), |
4444c779eb48 | atagen | 2026-10-16 12:07 UTC | 53 | move_mode: MoveMode::Swap, |
24fca1aad608 | atagen | 2026-10-17 09:56 UTC | 54 | focus_follows_mouse: false, |
24fca1aad608 | atagen | 2026-10-17 09:56 UTC | 55 | mouse_follows_focus: false, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 56 | } |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 57 | } |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 58 | } |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 59 | |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 60 | #[derive(Deserialize, Debug, Clone, Copy, PartialEq)] |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 61 | #[serde(default, deny_unknown_fields)] |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 62 | pub struct Gaps { |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 63 | pub inner: f64, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 64 | pub outer: f64, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 65 | } |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 66 | |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 67 | impl Default for Gaps { |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 68 | fn default() -> Self { |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 69 | Self { |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 70 | inner: 8.0, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 71 | outer: 8.0, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 72 | } |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 73 | } |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 74 | } |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 75 | |
8e6f96f0a32d | atagen | 2026-10-16 22:17 UTC | 76 | #[derive(Deserialize, Debug, Clone, PartialEq, Default)] |
8e6f96f0a32d | atagen | 2026-10-16 22:17 UTC | 77 | #[serde(default, deny_unknown_fields)] |
8e6f96f0a32d | atagen | 2026-10-16 22:17 UTC | 78 | pub struct Outputs { |
8e6f96f0a32d | atagen | 2026-10-16 22:17 UTC | 79 | pub vrr: Vrr, |
8e6f96f0a32d | atagen | 2026-10-16 22:17 UTC | 80 | } |
8e6f96f0a32d | atagen | 2026-10-16 22:17 UTC | 81 | |
8e6f96f0a32d | atagen | 2026-10-16 22:17 UTC | 82 | #[derive(Deserialize, Debug, Clone, Copy, PartialEq, Eq, Default)] |
8e6f96f0a32d | atagen | 2026-10-16 22:17 UTC | 83 | #[serde(rename_all = "lowercase")] |
8e6f96f0a32d | atagen | 2026-10-16 22:17 UTC | 84 | pub enum Vrr { |
8e6f96f0a32d | atagen | 2026-10-16 22:17 UTC | 85 | Off, |
8e6f96f0a32d | atagen | 2026-10-16 22:17 UTC | 86 | On, |
8e6f96f0a32d | atagen | 2026-10-16 22:17 UTC | 87 | /// Only while a fullscreen window is shown, where a game sets the pace. |
8e6f96f0a32d | atagen | 2026-10-16 22:17 UTC | 88 | #[default] |
8e6f96f0a32d | atagen | 2026-10-16 22:17 UTC | 89 | Fullscreen, |
8e6f96f0a32d | atagen | 2026-10-16 22:17 UTC | 90 | } |
8e6f96f0a32d | atagen | 2026-10-16 22:17 UTC | 91 | |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 92 | #[derive(Deserialize, Debug, Clone, PartialEq)] |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 93 | #[serde(default, deny_unknown_fields)] |
7ce6ae4e5a85 | atagen | 2026-10-16 12:16 UTC | 94 | pub struct Decoration { |
7ce6ae4e5a85 | atagen | 2026-10-16 12:16 UTC | 95 | /// Border width in logical pixels, drawn in the gap around each window. |
7ce6ae4e5a85 | atagen | 2026-10-16 12:16 UTC | 96 | pub border: u32, |
7ce6ae4e5a85 | atagen | 2026-10-16 12:16 UTC | 97 | pub focused: Color, |
7ce6ae4e5a85 | atagen | 2026-10-16 12:16 UTC | 98 | pub unfocused: Color, |
7ce6ae4e5a85 | atagen | 2026-10-16 12:16 UTC | 99 | } |
7ce6ae4e5a85 | atagen | 2026-10-16 12:16 UTC | 100 | |
7ce6ae4e5a85 | atagen | 2026-10-16 12:16 UTC | 101 | impl Default for Decoration { |
7ce6ae4e5a85 | atagen | 2026-10-16 12:16 UTC | 102 | fn default() -> Self { |
7ce6ae4e5a85 | atagen | 2026-10-16 12:16 UTC | 103 | Self { |
7ce6ae4e5a85 | atagen | 2026-10-16 12:16 UTC | 104 | border: 2, |
b22c0511d5af | atagen | 2026-10-17 03:48 UTC | 105 | focused: Color::rgb(0x88, 0xbf, 0xd1), |
b22c0511d5af | atagen | 2026-10-17 03:48 UTC | 106 | unfocused: Color::rgb(0x3b, 0x42, 0x52), |
7ce6ae4e5a85 | atagen | 2026-10-16 12:16 UTC | 107 | } |
7ce6ae4e5a85 | atagen | 2026-10-16 12:16 UTC | 108 | } |
7ce6ae4e5a85 | atagen | 2026-10-16 12:16 UTC | 109 | } |
7ce6ae4e5a85 | atagen | 2026-10-16 12:16 UTC | 110 | |
7ce6ae4e5a85 | atagen | 2026-10-16 12:16 UTC | 111 | /// Straight RGBA from `#rrggbb` or `#rrggbbaa`. |
7ce6ae4e5a85 | atagen | 2026-10-16 12:16 UTC | 112 | #[derive(Debug, Clone, Copy, PartialEq)] |
7ce6ae4e5a85 | atagen | 2026-10-16 12:16 UTC | 113 | pub struct Color(pub [f32; 4]); |
7ce6ae4e5a85 | atagen | 2026-10-16 12:16 UTC | 114 | |
b22c0511d5af | atagen | 2026-10-17 03:48 UTC | 115 | impl Color { |
b22c0511d5af | atagen | 2026-10-17 03:48 UTC | 116 | pub const fn rgb(r: u8, g: u8, b: u8) -> Self { |
b22c0511d5af | atagen | 2026-10-17 03:48 UTC | 117 | Self([r as f32 / 255.0, g as f32 / 255.0, b as f32 / 255.0, 1.0]) |
b22c0511d5af | atagen | 2026-10-17 03:48 UTC | 118 | } |
b22c0511d5af | atagen | 2026-10-17 03:48 UTC | 119 | } |
b22c0511d5af | atagen | 2026-10-17 03:48 UTC | 120 | |
7ce6ae4e5a85 | atagen | 2026-10-16 12:16 UTC | 121 | impl<'de> Deserialize<'de> for Color { |
7ce6ae4e5a85 | atagen | 2026-10-16 12:16 UTC | 122 | fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> { |
7ce6ae4e5a85 | atagen | 2026-10-16 12:16 UTC | 123 | let s = String::deserialize(d)?; |
7ce6ae4e5a85 | atagen | 2026-10-16 12:16 UTC | 124 | let hex = s.strip_prefix('#').unwrap_or(&s); |
7ce6ae4e5a85 | atagen | 2026-10-16 12:16 UTC | 125 | let bad = |
7ce6ae4e5a85 | atagen | 2026-10-16 12:16 UTC | 126 | || serde::de::Error::custom(format!("bad colour {s:?}, use #rrggbb or #rrggbbaa")); |
7ce6ae4e5a85 | atagen | 2026-10-16 12:16 UTC | 127 | if !matches!(hex.len(), 6 | 8) || !hex.is_ascii() { |
7ce6ae4e5a85 | atagen | 2026-10-16 12:16 UTC | 128 | return Err(bad()); |
7ce6ae4e5a85 | atagen | 2026-10-16 12:16 UTC | 129 | } |
7ce6ae4e5a85 | atagen | 2026-10-16 12:16 UTC | 130 | let mut c = [1.0f32; 4]; |
7ce6ae4e5a85 | atagen | 2026-10-16 12:16 UTC | 131 | for (i, v) in c.iter_mut().enumerate().take(hex.len() / 2) { |
7ce6ae4e5a85 | atagen | 2026-10-16 12:16 UTC | 132 | let byte = u8::from_str_radix(&hex[i * 2..i * 2 + 2], 16).map_err(|_| bad())?; |
7ce6ae4e5a85 | atagen | 2026-10-16 12:16 UTC | 133 | *v = f32::from(byte) / 255.0; |
7ce6ae4e5a85 | atagen | 2026-10-16 12:16 UTC | 134 | } |
7ce6ae4e5a85 | atagen | 2026-10-16 12:16 UTC | 135 | Ok(Self(c)) |
7ce6ae4e5a85 | atagen | 2026-10-16 12:16 UTC | 136 | } |
7ce6ae4e5a85 | atagen | 2026-10-16 12:16 UTC | 137 | } |
7ce6ae4e5a85 | atagen | 2026-10-16 12:16 UTC | 138 | |
7ce6ae4e5a85 | atagen | 2026-10-16 12:16 UTC | 139 | #[derive(Deserialize, Debug, Clone, PartialEq)] |
7ce6ae4e5a85 | atagen | 2026-10-16 12:16 UTC | 140 | #[serde(default, deny_unknown_fields)] |
2af1d8c55876 | atagen | 2026-10-16 11:05 UTC | 141 | pub struct Animation { |
2af1d8c55876 | atagen | 2026-10-16 11:05 UTC | 142 | pub enabled: bool, |
2af1d8c55876 | atagen | 2026-10-16 11:05 UTC | 143 | pub style: AnimationStyle, |
2af1d8c55876 | atagen | 2026-10-16 11:05 UTC | 144 | /// Every phase of a planned transition lasts this long. |
2af1d8c55876 | atagen | 2026-10-16 11:05 UTC | 145 | pub phase_ms: u64, |
2af1d8c55876 | atagen | 2026-10-16 11:05 UTC | 146 | /// A cubic bezier, as in CSS. |
2af1d8c55876 | atagen | 2026-10-16 11:05 UTC | 147 | pub curve: [f64; 4], |
2af1d8c55876 | atagen | 2026-10-16 11:05 UTC | 148 | } |
2af1d8c55876 | atagen | 2026-10-16 11:05 UTC | 149 | |
2af1d8c55876 | atagen | 2026-10-16 11:05 UTC | 150 | impl Default for Animation { |
2af1d8c55876 | atagen | 2026-10-16 11:05 UTC | 151 | fn default() -> Self { |
2af1d8c55876 | atagen | 2026-10-16 11:05 UTC | 152 | Self { |
2af1d8c55876 | atagen | 2026-10-16 11:05 UTC | 153 | enabled: true, |
2af1d8c55876 | atagen | 2026-10-16 11:05 UTC | 154 | style: AnimationStyle::Orthogonal, |
2af1d8c55876 | atagen | 2026-10-16 11:05 UTC | 155 | phase_ms: 160, |
2af1d8c55876 | atagen | 2026-10-16 11:05 UTC | 156 | curve: [0.45, 0.0, 0.2, 1.0], |
2af1d8c55876 | atagen | 2026-10-16 11:05 UTC | 157 | } |
2af1d8c55876 | atagen | 2026-10-16 11:05 UTC | 158 | } |
2af1d8c55876 | atagen | 2026-10-16 11:05 UTC | 159 | } |
2af1d8c55876 | atagen | 2026-10-16 11:05 UTC | 160 | |
2af1d8c55876 | atagen | 2026-10-16 11:05 UTC | 161 | #[derive(Deserialize, Debug, Clone, Copy, PartialEq, Eq)] |
2af1d8c55876 | atagen | 2026-10-16 11:05 UTC | 162 | #[serde(rename_all = "lowercase")] |
2af1d8c55876 | atagen | 2026-10-16 11:05 UTC | 163 | pub enum AnimationStyle { |
2af1d8c55876 | atagen | 2026-10-16 11:05 UTC | 164 | Orthogonal, |
2af1d8c55876 | atagen | 2026-10-16 11:05 UTC | 165 | Direct, |
2af1d8c55876 | atagen | 2026-10-16 11:05 UTC | 166 | } |
2af1d8c55876 | atagen | 2026-10-16 11:05 UTC | 167 | |
2af1d8c55876 | atagen | 2026-10-16 11:05 UTC | 168 | #[derive(Deserialize, Debug, Clone, PartialEq)] |
2af1d8c55876 | atagen | 2026-10-16 11:05 UTC | 169 | #[serde(default, deny_unknown_fields)] |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 170 | pub struct Keyboard { |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 171 | pub rules: String, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 172 | pub model: String, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 173 | pub layout: String, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 174 | pub variant: String, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 175 | pub options: Option<String>, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 176 | pub repeat_delay: i32, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 177 | pub repeat_rate: i32, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 178 | } |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 179 | |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 180 | impl Default for Keyboard { |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 181 | fn default() -> Self { |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 182 | Self { |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 183 | rules: String::new(), |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 184 | model: String::new(), |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 185 | layout: String::new(), |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 186 | variant: String::new(), |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 187 | options: None, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 188 | repeat_delay: 200, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 189 | repeat_rate: 25, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 190 | } |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 191 | } |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 192 | } |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 193 | |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 194 | #[derive(Deserialize, Debug, Clone, Copy, PartialEq, Eq)] |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 195 | #[serde(rename_all = "lowercase")] |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 196 | pub enum Modifier { |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 197 | Super, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 198 | Alt, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 199 | Ctrl, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 200 | Shift, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 201 | } |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 202 | |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 203 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Hash)] |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 204 | pub struct Mods { |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 205 | pub logo: bool, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 206 | pub alt: bool, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 207 | pub ctrl: bool, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 208 | pub shift: bool, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 209 | } |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 210 | |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 211 | impl Mods { |
b22c0511d5af | atagen | 2026-10-17 03:48 UTC | 212 | pub fn has(&self, m: Modifier) -> bool { |
b22c0511d5af | atagen | 2026-10-17 03:48 UTC | 213 | match m { |
b22c0511d5af | atagen | 2026-10-17 03:48 UTC | 214 | Modifier::Super => self.logo, |
b22c0511d5af | atagen | 2026-10-17 03:48 UTC | 215 | Modifier::Alt => self.alt, |
b22c0511d5af | atagen | 2026-10-17 03:48 UTC | 216 | Modifier::Ctrl => self.ctrl, |
b22c0511d5af | atagen | 2026-10-17 03:48 UTC | 217 | Modifier::Shift => self.shift, |
b22c0511d5af | atagen | 2026-10-17 03:48 UTC | 218 | } |
b22c0511d5af | atagen | 2026-10-17 03:48 UTC | 219 | } |
b22c0511d5af | atagen | 2026-10-17 03:48 UTC | 220 | |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 221 | fn set(&mut self, m: Modifier) { |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 222 | match m { |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 223 | Modifier::Super => self.logo = true, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 224 | Modifier::Alt => self.alt = true, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 225 | Modifier::Ctrl => self.ctrl = true, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 226 | Modifier::Shift => self.shift = true, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 227 | } |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 228 | } |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 229 | } |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 230 | |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 231 | #[derive(Debug, Clone, PartialEq)] |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 232 | pub struct Bind { |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 233 | pub mods: Mods, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 234 | /// An xkb keysym name, resolved by the compositor. |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 235 | pub key: String, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 236 | pub command: Command, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 237 | } |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 238 | |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 239 | #[derive(Debug, Clone)] |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 240 | pub struct Rule { |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 241 | pub app_id: Option<Regex>, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 242 | pub title: Option<Regex>, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 243 | pub tag: Option<String>, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 244 | pub output: Option<String>, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 245 | pub floating: Option<bool>, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 246 | pub sticky: Option<bool>, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 247 | pub scratchpad: Option<String>, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 248 | } |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 249 | |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 250 | /// Everything the matching rules say about a window, later rules winning. |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 251 | #[derive(Debug, Clone, Default, PartialEq)] |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 252 | pub struct Placement { |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 253 | pub tag: Option<String>, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 254 | pub output: Option<String>, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 255 | pub floating: Option<bool>, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 256 | pub sticky: Option<bool>, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 257 | pub scratchpad: Option<String>, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 258 | } |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 259 | |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 260 | #[derive(Debug)] |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 261 | pub enum Error { |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 262 | Io(PathBuf, std::io::Error), |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 263 | Toml(toml::de::Error), |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 264 | Bind(String, String), |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 265 | Regex(String, regex::Error), |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 266 | } |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 267 | |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 268 | impl fmt::Display for Error { |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 269 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 270 | match self { |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 271 | Error::Io(p, e) => write!(f, "{}: {e}", p.display()), |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 272 | Error::Toml(e) => write!(f, "{e}"), |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 273 | Error::Bind(k, e) => write!(f, "bind {k:?}: {e}"), |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 274 | Error::Regex(r, e) => write!(f, "rule pattern {r:?}: {e}"), |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 275 | } |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 276 | } |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 277 | } |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 278 | |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 279 | impl std::error::Error for Error {} |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 280 | |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 281 | #[derive(Deserialize)] |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 282 | #[serde(deny_unknown_fields)] |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 283 | struct Raw { |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 284 | #[serde(default)] |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 285 | startup: Vec<Vec<String>>, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 286 | #[serde(default)] |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 287 | general: General, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 288 | #[serde(default)] |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 289 | keyboard: Keyboard, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 290 | #[serde(default)] |
2af1d8c55876 | atagen | 2026-10-16 11:05 UTC | 291 | animation: Animation, |
2af1d8c55876 | atagen | 2026-10-16 11:05 UTC | 292 | #[serde(default)] |
7ce6ae4e5a85 | atagen | 2026-10-16 12:16 UTC | 293 | decoration: Decoration, |
7ce6ae4e5a85 | atagen | 2026-10-16 12:16 UTC | 294 | #[serde(default)] |
8e6f96f0a32d | atagen | 2026-10-16 22:17 UTC | 295 | output: Outputs, |
8e6f96f0a32d | atagen | 2026-10-16 22:17 UTC | 296 | #[serde(default)] |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 297 | binds: BTreeMap<String, Words>, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 298 | #[serde(default)] |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 299 | rules: Vec<RawRule>, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 300 | } |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 301 | |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 302 | #[derive(Deserialize)] |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 303 | #[serde(untagged)] |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 304 | enum Words { |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 305 | Line(String), |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 306 | List(Vec<String>), |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 307 | } |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 308 | |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 309 | #[derive(Deserialize)] |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 310 | #[serde(deny_unknown_fields)] |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 311 | struct RawRule { |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 312 | app_id: Option<String>, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 313 | title: Option<String>, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 314 | tag: Option<String>, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 315 | output: Option<String>, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 316 | floating: Option<bool>, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 317 | sticky: Option<bool>, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 318 | scratchpad: Option<String>, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 319 | } |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 320 | |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 321 | impl Config { |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 322 | /// `$MONOLITH_CONFIG`, else `$XDG_CONFIG_HOME/monolith/config.toml`. |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 323 | pub fn path() -> Option<PathBuf> { |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 324 | if let Some(p) = std::env::var_os("MONOLITH_CONFIG") { |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 325 | return Some(p.into()); |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 326 | } |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 327 | let base = std::env::var_os("XDG_CONFIG_HOME") |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 328 | .map(PathBuf::from) |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 329 | .or_else(|| std::env::var_os("HOME").map(|h| PathBuf::from(h).join(".config")))?; |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 330 | Some(base.join("monolith/config.toml")) |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 331 | } |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 332 | |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 333 | /// Loads `path`, or the built-in default when it does not exist. |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 334 | pub fn load(path: Option<&Path>) -> Result<Self, Error> { |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 335 | match path { |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 336 | Some(p) => match std::fs::read_to_string(p) { |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 337 | Ok(text) => Self::parse(&text), |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 338 | Err(e) if e.kind() == std::io::ErrorKind::NotFound => Self::parse(DEFAULT), |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 339 | Err(e) => Err(Error::Io(p.to_owned(), e)), |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 340 | }, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 341 | None => Self::parse(DEFAULT), |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 342 | } |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 343 | } |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 344 | |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 345 | pub fn parse(text: &str) -> Result<Self, Error> { |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 346 | let raw: Raw = toml::from_str(text).map_err(Error::Toml)?; |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 347 | let mod_key = raw.general.mod_key; |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 348 | let binds = raw |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 349 | .binds |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 350 | .into_iter() |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 351 | .map(|(combo, words)| parse_bind(&combo, words, mod_key)) |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 352 | .collect::<Result<_, _>>()?; |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 353 | let regex = |p: Option<String>| { |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 354 | p.map(|p| Regex::new(&p).map_err(|e| Error::Regex(p, e))) |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 355 | .transpose() |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 356 | }; |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 357 | let rules = raw |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 358 | .rules |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 359 | .into_iter() |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 360 | .map(|r| { |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 361 | Ok(Rule { |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 362 | app_id: regex(r.app_id)?, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 363 | title: regex(r.title)?, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 364 | tag: r.tag, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 365 | output: r.output, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 366 | floating: r.floating, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 367 | sticky: r.sticky, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 368 | scratchpad: r.scratchpad, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 369 | }) |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 370 | }) |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 371 | .collect::<Result<_, Error>>()?; |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 372 | Ok(Self { |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 373 | general: raw.general, |
2af1d8c55876 | atagen | 2026-10-16 11:05 UTC | 374 | animation: raw.animation, |
7ce6ae4e5a85 | atagen | 2026-10-16 12:16 UTC | 375 | decoration: raw.decoration, |
8e6f96f0a32d | atagen | 2026-10-16 22:17 UTC | 376 | output: raw.output, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 377 | keyboard: raw.keyboard, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 378 | binds, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 379 | rules, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 380 | startup: raw.startup, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 381 | }) |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 382 | } |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 383 | |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 384 | pub fn placement(&self, app_id: &str, title: &str) -> Placement { |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 385 | let mut p = Placement::default(); |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 386 | let hit = |re: &Option<Regex>, s: &str| re.as_ref().is_none_or(|re| re.is_match(s)); |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 387 | for r in &self.rules { |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 388 | if !hit(&r.app_id, app_id) || !hit(&r.title, title) { |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 389 | continue; |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 390 | } |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 391 | p.tag = r.tag.clone().or(p.tag); |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 392 | p.output = r.output.clone().or(p.output); |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 393 | p.floating = r.floating.or(p.floating); |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 394 | p.sticky = r.sticky.or(p.sticky); |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 395 | p.scratchpad = r.scratchpad.clone().or(p.scratchpad); |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 396 | } |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 397 | p |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 398 | } |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 399 | } |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 400 | |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 401 | fn parse_bind(combo: &str, words: Words, mod_key: Modifier) -> Result<Bind, Error> { |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 402 | let bad = |m: String| Error::Bind(combo.to_owned(), m); |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 403 | let parts: Vec<&str> = combo.split('+').map(str::trim).collect(); |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 404 | let Some((&key, mods)) = parts.split_last().filter(|(k, _)| !k.is_empty()) else { |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 405 | return Err(bad("no key".into())); |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 406 | }; |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 407 | let mut set = Mods::default(); |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 408 | for m in mods { |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 409 | let m = match m.to_ascii_lowercase().as_str() { |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 410 | "mod" => mod_key, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 411 | "super" | "logo" | "win" => Modifier::Super, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 412 | "alt" => Modifier::Alt, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 413 | "ctrl" | "control" => Modifier::Ctrl, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 414 | "shift" => Modifier::Shift, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 415 | other => return Err(bad(format!("unknown modifier {other}"))), |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 416 | }; |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 417 | set.set(m); |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 418 | } |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 419 | let words: Vec<String> = match words { |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 420 | Words::Line(s) => s.split_whitespace().map(str::to_owned).collect(), |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 421 | Words::List(v) => v, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 422 | }; |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 423 | let command = Command::parse(&words).map_err(|e| bad(e.0))?; |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 424 | Ok(Bind { |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 425 | mods: set, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 426 | key: key.to_owned(), |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 427 | command, |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 428 | }) |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 429 | } |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 430 | |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 431 | #[cfg(test)] |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 432 | mod tests { |
b22c0511d5af | atagen | 2026-10-17 03:48 UTC | 433 | use super::*; |
b22c0511d5af | atagen | 2026-10-17 03:48 UTC | 434 | |
b22c0511d5af | atagen | 2026-10-17 03:48 UTC | 435 | /// default.toml documents the defaults for users, and the Default impls |
b22c0511d5af | atagen | 2026-10-17 03:48 UTC | 436 | /// apply them to sections a user config leaves out. They must agree. |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 437 | #[test] |
b22c0511d5af | atagen | 2026-10-17 03:48 UTC | 438 | fn default_toml_states_the_defaults() { |
b22c0511d5af | atagen | 2026-10-17 03:48 UTC | 439 | let c = Config::parse(DEFAULT).unwrap(); |
b22c0511d5af | atagen | 2026-10-17 03:48 UTC | 440 | assert_eq!(c.general, General::default()); |
b22c0511d5af | atagen | 2026-10-17 03:48 UTC | 441 | assert_eq!(c.output, Outputs::default()); |
b22c0511d5af | atagen | 2026-10-17 03:48 UTC | 442 | assert_eq!(c.decoration, Decoration::default()); |
b22c0511d5af | atagen | 2026-10-17 03:48 UTC | 443 | assert_eq!(c.animation, Animation::default()); |
b22c0511d5af | atagen | 2026-10-17 03:48 UTC | 444 | assert_eq!(c.keyboard, Keyboard::default()); |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 445 | assert!(c.binds.len() > 40); |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 446 | } |
fe835aed6c8d | atagen | 2026-10-16 10:05 UTC | 447 | } |