Skip to main content

hyprshell_config_lib/
structs.rs

1use crate::Modifier;
2use std::path::Path;
3
4#[derive(Debug, Clone, PartialEq)]
5pub struct Config {
6    pub windows: Option<Windows>,
7}
8
9impl Default for Config {
10    fn default() -> Self {
11        crate::io::Config::default()
12            .try_into()
13            .expect("the default config invalid")
14    }
15}
16
17#[derive(Debug, Clone, PartialEq)]
18pub struct Windows {
19    pub general: WindowsGeneral,
20    pub overview: Option<Overview>,
21    pub switch: Option<Switch>,
22    pub switch_2: Option<Switch>,
23}
24
25impl Default for Windows {
26    fn default() -> Self {
27        crate::io::Windows::default()
28            .try_into()
29            .expect("the default config invalid")
30    }
31}
32
33#[derive(Debug, Clone, PartialEq)]
34pub struct WindowsGeneral {
35    pub scale: f64,
36    pub items_per_row: u8,
37}
38
39#[derive(Debug, Clone, PartialEq)]
40pub struct Overview {
41    pub launcher: Launcher,
42    pub key: Box<str>,
43    pub top_offset: u16,
44    pub modifier: Modifier,
45    pub filter_by_same_class: bool,
46    pub filter_by_current_workspace: bool,
47    pub filter_by_current_monitor: bool,
48    pub exclude_workspaces: Box<str>,
49}
50
51impl Default for Overview {
52    fn default() -> Self {
53        crate::io::Overview::default()
54            .try_into()
55            .expect("the default config invalid")
56    }
57}
58
59#[derive(Debug, Clone, PartialEq)]
60pub struct Launcher {
61    pub default_terminal: Option<Box<str>>,
62    pub launch_modifier: Modifier,
63    pub width: u16,
64    pub max_items: u8,
65    pub show_when_empty: bool,
66    pub plugins: Plugins,
67}
68
69impl Default for Launcher {
70    fn default() -> Self {
71        crate::io::Launcher::default()
72            .try_into()
73            .expect("the default config invalid")
74    }
75}
76
77#[derive(Debug, Clone, PartialEq)]
78pub struct Plugins {
79    pub applications: Option<ApplicationsPluginConfig>,
80    pub terminal: Option<()>,
81    pub shell: Option<()>,
82    pub websearch: Option<WebSearchConfig>,
83    pub calc: Option<()>,
84    pub path: Option<()>,
85    pub actions: Option<ActionsPluginConfig>,
86}
87
88#[derive(Debug, Clone, PartialEq)]
89pub struct ActionsPluginConfig {
90    pub actions: Vec<ActionsPluginAction>,
91}
92
93impl Default for ActionsPluginConfig {
94    fn default() -> Self {
95        crate::io::ActionsPluginConfig::default()
96            .try_into()
97            .expect("the default config invalid")
98    }
99}
100
101#[derive(Debug, Clone, Eq, PartialEq)]
102pub struct ApplicationsPluginConfig {
103    pub run_cache_weeks: u8,
104    pub show_execs: bool,
105    pub show_actions_submenu: bool,
106}
107
108impl Default for ApplicationsPluginConfig {
109    fn default() -> Self {
110        crate::io::ApplicationsPluginConfig::default()
111            .try_into()
112            .expect("the default config invalid")
113    }
114}
115
116#[derive(Debug, Clone, PartialEq)]
117pub enum ActionsPluginAction {
118    LockScreen,
119    Hibernate,
120    Logout,
121    Reboot,
122    Shutdown,
123    Suspend,
124    Custom(ActionsPluginActionCustom),
125}
126
127#[derive(Debug, Clone, Eq, PartialEq)]
128pub struct ActionsPluginActionCustom {
129    pub names: Vec<Box<str>>,
130    pub details: Box<str>,
131    pub command: Box<str>,
132    pub icon: Box<Path>,
133}
134
135#[derive(Debug, Clone, PartialEq)]
136pub struct WebSearchConfig {
137    pub engines: Vec<SearchEngine>,
138}
139
140impl Default for WebSearchConfig {
141    fn default() -> Self {
142        crate::io::WebSearchConfig::default()
143            .try_into()
144            .expect("the default config invalid")
145    }
146}
147
148#[derive(Debug, Clone, Eq, PartialEq)]
149pub struct SearchEngine {
150    pub url: Box<str>,
151    pub name: Box<str>,
152    pub key: char,
153}
154
155#[derive(Debug, Clone, Eq, PartialEq)]
156pub struct Switch {
157    pub modifier: Modifier,
158    pub key: Box<str>,
159    pub filter_by_same_class: bool,
160    pub filter_by_current_workspace: bool,
161    pub filter_by_current_monitor: bool,
162    pub switch_workspaces: bool,
163    pub exclude_workspaces: Box<str>,
164    pub kill_key: char,
165}
166
167impl Default for Switch {
168    fn default() -> Self {
169        crate::io::Switch::default()
170            .try_into()
171            .expect("the default config invalid")
172    }
173}