almost_everything/
almost_everything.rs1use hyprland::data::{Client, Clients, Monitors, Workspace};
2use hyprland::dispatch::*;
3use hyprland::event_listener::EventListenerMutable as EventListener;
4use hyprland::keyword::*;
5use hyprland::prelude::*;
6use hyprland::shared::WorkspaceType;
7
8fn main() -> hyprland::Result<()> {
9 hyprland::dispatch!(Exec, "kitty")?;
14
15 Dispatch::call(DispatchType::MoveCursorToCorner(Corner::TopLeft))?;
18
19 hyprland::bind!(SUPER, Key, "i" => ToggleFloating, None)?;
21
22 let border_size = match Keyword::get("general:border_size")?.value {
24 OptionValue::Int(i) => i,
25 _ => panic!("border size can only be a int"),
26 };
27 println!("{border_size}");
28
29 Keyword::set("general:border_size", border_size * 2)?;
31
32 let monitors = Monitors::get()?;
34
35 let win = Client::get_active()?;
37
38 let clients = Clients::get()?;
40
41 let work = Workspace::get_active()?;
43
44 println!("monitors: {monitors:#?},\nactive window: {win:#?},\nclients {clients:#?}\nworkspace: {work:#?}");
46
47 let mut event_listener = EventListener::new();
49
50 event_listener.add_active_window_change_handler(|data, _| {
52 println!("{data:#?}");
53 });
54
55 event_listener.add_workspace_change_handler(|id, state| {
58 if id == WorkspaceType::Regular('9'.to_string()) {
59 state.active_workspace = WorkspaceType::Regular('2'.to_string());
60 }
61 });
62 event_listener.add_fullscreen_state_change_handler(|fstate, state| {
64 if fstate {
65 state.fullscreen_state = false;
66 }
67 });
68 event_listener.add_active_monitor_change_handler(|data, state| {
70 let hyprland::event_listener::MonitorEventData { monitor_name, .. } = data;
71
72 if monitor_name == *"DP-1".to_string() {
73 state.active_monitor = "eDP-1".to_string()
74 }
75 });
76
77 event_listener.add_workspace_change_handler(|id, _| println!("workspace changed to {id:#?}"));
79
80 event_listener.start_listener()
84}