hyprshell_config_lib/
actions.rs

1use crate::{ActionsPluginAction, ActionsPluginActionCustom};
2use std::path::PathBuf;
3
4pub trait ToAction {
5    fn to_action(self) -> ActionsPluginActionCustom;
6}
7
8impl ToAction for ActionsPluginAction {
9    fn to_action(self) -> ActionsPluginActionCustom {
10        match self {
11            Self::LockScreen => ActionsPluginActionCustom {
12                names: vec![Box::from("Lock Screen")],
13                details: Box::from("Lock the screen"),
14                command: Box::from("loginctl lock-session"),
15                icon: PathBuf::from("system-lock-screen").into_boxed_path(),
16            },
17            Self::Hibernate => ActionsPluginActionCustom {
18                names: vec![Box::from("Hibernate")],
19                details: Box::from("Hibernate the computer"),
20                command: Box::from("systemctl hibernate"),
21                icon: PathBuf::from("system-hibernate").into_boxed_path(),
22            },
23            Self::Logout => ActionsPluginActionCustom {
24                names: vec![Box::from("Log Out"), Box::from("Logout")],
25                details: Box::from("Log out of the session"),
26                command: Box::from("loginctl terminate-session self"),
27                icon: PathBuf::from("system-log-out").into_boxed_path(),
28            },
29            Self::Reboot => ActionsPluginActionCustom {
30                names: vec![Box::from("Reboot"), Box::from("Restart")],
31                details: Box::from("Reboot the computer"),
32                command: Box::from("systemctl reboot"),
33                icon: PathBuf::from("system-reboot").into_boxed_path(),
34            },
35            Self::Shutdown => ActionsPluginActionCustom {
36                names: vec![Box::from("Shut Down"), Box::from("Power off")],
37                details: Box::from("Shut down the computer"),
38                command: Box::from("systemctl poweroff"),
39                icon: PathBuf::from("system-shutdown").into_boxed_path(),
40            },
41            Self::Suspend => ActionsPluginActionCustom {
42                names: vec![Box::from("Sleep"), Box::from("Suspend")],
43                details: Box::from("Put the computer to sleep"),
44                command: Box::from("systemctl suspend"),
45                icon: PathBuf::from("system-suspend").into_boxed_path(),
46            },
47            Self::Custom(c) => c,
48        }
49    }
50}