hyprshell_core_lib/transfer/
structs.rs

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