azalea_core/
config.rs

1//! Configuration structs
2
3use std::collections::HashMap;
4
5pub mod layer_shell {
6    use clap::Parser;
7
8    pub type Namespace = String;
9
10    #[derive(clap::ValueEnum, serde::Serialize, serde::Deserialize, Debug, Clone)]
11    pub enum Layer {
12        Background,
13        Bottom,
14        Top,
15        Overlay,
16    }
17
18    impl Into<gtk4_layer_shell::Layer> for &Layer {
19        fn into(self) -> gtk4_layer_shell::Layer {
20            match self {
21                Layer::Background => gtk4_layer_shell::Layer::Background,
22                Layer::Bottom => gtk4_layer_shell::Layer::Bottom,
23                Layer::Top => gtk4_layer_shell::Layer::Top,
24                Layer::Overlay => gtk4_layer_shell::Layer::Overlay,
25            }
26        }
27    }
28
29    #[derive(clap::ValueEnum, serde::Serialize, serde::Deserialize, Debug, Clone)]
30    pub enum Anchor {
31        Top,
32        Bottom,
33        Left,
34        Right,
35    }
36
37    impl Into<gtk4_layer_shell::Edge> for &Anchor {
38        fn into(self) -> gtk4_layer_shell::Edge {
39            match self {
40                Anchor::Top => gtk4_layer_shell::Edge::Top,
41                Anchor::Bottom => gtk4_layer_shell::Edge::Bottom,
42                Anchor::Left => gtk4_layer_shell::Edge::Left,
43                Anchor::Right => gtk4_layer_shell::Edge::Right,
44            }
45        }
46    }
47
48    #[derive(clap::ValueEnum, Default, serde::Serialize, serde::Deserialize, Debug, Clone)]
49    pub enum ExclusiveZone {
50        /// Let gtk-layer-shell calculate it
51        Auto,
52
53        /// -1
54        Ignore,
55
56        /// 0
57        #[default]
58        Normal,
59    }
60
61    #[derive(Parser, serde::Serialize, serde::Deserialize, Debug, Clone)]
62    pub struct Config {
63        pub namespace: Namespace,
64
65        #[clap(long)]
66        pub layer: Layer,
67
68        #[clap(long)]
69        pub anchors: Vec<Anchor>,
70
71        #[clap(long)]
72        pub exclusive_zone: ExclusiveZone,
73    }
74}
75
76pub mod window {
77    use crate::monitor::Monitor;
78
79    use super::layer_shell;
80
81    pub type Id = String;
82
83    /// Template configuration for a window
84    #[derive(Clone, serde::Serialize, serde::Deserialize, Debug)]
85    pub struct Config<ConfigWrapper>
86    where
87        ConfigWrapper: std::fmt::Debug + Clone,
88    {
89        pub config: ConfigWrapper,
90        pub layer_shell: Option<layer_shell::Config>,
91        #[serde(default)]
92        pub lazy: bool,
93        #[serde(default)]
94        pub monitor: Monitor,
95    }
96}
97
98#[derive(Debug, serde::Serialize, serde::Deserialize)]
99pub struct Config<ConfigWrapper>
100where
101    ConfigWrapper: std::fmt::Debug + Clone,
102{
103    pub windows: HashMap<window::Id, window::Config<ConfigWrapper>>,
104    // TODO: Add different layouts (which windows are active)
105}