Skip to main content

hyprshell_core_lib/transfer/
structs.rs

1use crate::{ClientId, WorkspaceId};
2use serde::{Deserialize, Serialize};
3
4#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)]
5pub enum ExternalTransferType {
6    /// send from the keybind to open the overview
7    OpenOverview,
8    /// send from the keybind to open the switch
9    OpenSwitch(OpenSwitch),
10    /// send from releasing the mod key
11    CloseSwitch(CloseSwitch),
12    /// send from the app itself when new monitor / config / css / hyprconfig changes detected
13    Reload,
14}
15#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)]
16pub struct OpenSwitch {
17    pub reverse: bool,
18}
19
20#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)]
21pub struct CloseSwitch {
22    pub switch: bool,
23}
24
25#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)]
26pub struct SwitchOverviewConfig {
27    pub direction: Direction,
28    pub workspace: bool,
29}
30
31#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)]
32pub struct SwitchSwitchConfig {
33    pub direction: Direction,
34}
35
36#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)]
37pub enum CloseOverviewConfig {
38    LauncherClick(Identifier),
39    LauncherPress(char),
40    Windows(WindowsOverride),
41    None,
42}
43
44#[derive(Debug, Serialize, Deserialize, Copy, Clone, Eq, PartialEq, Hash)]
45pub enum PluginName {
46    Applications,
47    Shell,
48    Terminal,
49    WebSearch,
50    Calc,
51    Path,
52    Actions,
53}
54
55#[derive(Debug, Clone, Eq, PartialEq, Hash, Serialize, Deserialize)]
56pub struct Identifier {
57    pub plugin: PluginName,
58    // identifies the box in the launcher results
59    pub data: Option<Box<str>>,
60    // additional data used to get suboption in submenu (only available when launched through click)
61    pub data_additional: Option<Box<str>>,
62}
63
64impl Identifier {
65    #[must_use]
66    pub const fn plugin(plugin: PluginName) -> Self {
67        Self {
68            plugin,
69            data: None,
70            data_additional: None,
71        }
72    }
73
74    #[must_use]
75    pub const fn data(plugin: PluginName, data: Box<str>) -> Self {
76        Self {
77            plugin,
78            data: Some(data),
79            data_additional: None,
80        }
81    }
82
83    #[must_use]
84    pub const fn data_additional(
85        plugin: PluginName,
86        data: Box<str>,
87        data_additional: Box<str>,
88    ) -> Self {
89        Self {
90            plugin,
91            data: Some(data),
92            data_additional: Some(data_additional),
93        }
94    }
95}
96
97#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)]
98pub enum WindowsOverride {
99    ClientId(ClientId),
100    WorkspaceID(WorkspaceId),
101}
102
103#[derive(Debug, Serialize, Deserialize, Eq, PartialEq)]
104pub enum Direction {
105    Right,
106    Left,
107    Up,
108    Down,
109}