hyprshell_core_lib/config/
check.rs

1use crate::config::Config;
2use anyhow::bail;
3
4pub fn check(config: &Config) -> anyhow::Result<()> {
5    if config
6        .windows
7        .as_ref()
8        .map(|w| w.scale >= 15f64 || w.scale <= 0f64)
9        .unwrap_or(false)
10    {
11        bail!("Scale factor must be less than 15 and greater than 0");
12    }
13
14    if let Some(l) = &config.launcher {
15        let mut used: Vec<char> = vec![];
16        for engine in l
17            .plugins
18            .websearch
19            .as_ref()
20            .map(|ws| &ws.engines)
21            .unwrap_or(&vec![])
22        {
23            if engine.url.is_empty() {
24                bail!("Search engine url cannot be empty");
25            }
26            if engine.name.is_empty() {
27                bail!("Search engine name cannot be empty");
28            }
29            if used.contains(&engine.key) {
30                bail!("Duplicate search engine key: {}", engine.key);
31            } else {
32                used.push(engine.key);
33            }
34        }
35        if l.plugins.calc.is_some() {
36            #[cfg(not(feature = "calc"))]
37            {
38                bail!("Calc Plugin enabled but not compiled in, please enable the calc feature");
39            }
40        }
41    };
42
43    Ok(())
44}