Struct AsyncEventListener
pub struct AsyncEventListener { /* private fields */ }
Expand description
This struct is used for adding event handlers and executing them on events
§The Event Listener
This struct holds what you need to create a event listener
§Usage
use hyprland::event_listener::EventListener;
let mut listener = EventListener::new(); // creates a new listener
// add a event handler which will be ran when this event happens
listener.add_workspace_change_handler(|data| println!("{:#?}", data));
listener.start_listener(); // or `.start_listener_async().await` if async
Implementations§
§impl AsyncEventListener
impl AsyncEventListener
pub fn new() -> AsyncEventListener
pub fn new() -> AsyncEventListener
This method creates a new EventListener instance
use hyprland::event_listener::EventListener;
let mut listener = EventListener::new();
pub async fn start_listener_async(&mut self) -> Result<(), HyprError>
pub async fn start_listener_async(&mut self) -> Result<(), HyprError>
This method starts the event listener (async)
This should be ran after all of your handlers are defined
use hyprland::event_listener::EventListener;
let mut listener = EventListener::new();
listener.add_workspace_change_handler(|id| println!("changed workspace to {id:?}"));
listener.start_listener_async().await;
§impl AsyncEventListener
impl AsyncEventListener
pub fn add_workspace_changed_handler(
&mut self,
f: impl Fn(WorkspaceEventData) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static,
)
pub fn add_workspace_changed_handler( &mut self, f: impl Fn(WorkspaceEventData) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static, )
This method adds an event which executes when on workspace change
use hyprland::event_listener::EventListener;
let mut listener = EventListener::new();
listener.add_workspace_changed_handler(|id| println!("changed workspace to: {id:#?}"));
listener.start_listener();
§impl AsyncEventListener
impl AsyncEventListener
pub fn add_workspace_added_handler(
&mut self,
f: impl Fn(WorkspaceEventData) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static,
)
pub fn add_workspace_added_handler( &mut self, f: impl Fn(WorkspaceEventData) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static, )
This method adds an event which executes when a workspace is created
use hyprland::event_listener::EventListener;
let mut listener = EventListener::new();
listener.add_workspace_added_handler(|id| println!("workspace was added: {id:#?}"));
listener.start_listener();
§impl AsyncEventListener
impl AsyncEventListener
pub fn add_workspace_deleted_handler(
&mut self,
f: impl Fn(WorkspaceEventData) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static,
)
pub fn add_workspace_deleted_handler( &mut self, f: impl Fn(WorkspaceEventData) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static, )
This method adds an event which executes when a workspace is destroyed
use hyprland::event_listener::EventListener;
let mut listener = EventListener::new();
listener.add_workspace_deleted_handler(|data| println!("a workspace was destroyed: {data:#?}"));
listener.start_listener();
§impl AsyncEventListener
impl AsyncEventListener
pub fn add_workspace_moved_handler(
&mut self,
f: impl Fn(WorkspaceMovedEventData) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static,
)
pub fn add_workspace_moved_handler( &mut self, f: impl Fn(WorkspaceMovedEventData) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static, )
This method adds an event which executes when a workspace is moved
use hyprland::event_listener::EventListener;
let mut listener = EventListener::new();
listener.add_workspace_moved_handler(|id| println!("workspace was moved: {id:#?}"));
listener.start_listener();
§impl AsyncEventListener
impl AsyncEventListener
pub fn add_workspace_renamed_handler(
&mut self,
f: impl Fn(NonSpecialWorkspaceEventData) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static,
)
pub fn add_workspace_renamed_handler( &mut self, f: impl Fn(NonSpecialWorkspaceEventData) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static, )
This method adds an event which executes when a workspace is renamed
use hyprland::event_listener::EventListener;
let mut listener = EventListener::new();
listener.add_workspace_renamed_handler(|id| println!("workspace was renamed: {id:#?}"));
listener.start_listener();
§impl AsyncEventListener
impl AsyncEventListener
pub fn add_active_monitor_changed_handler(
&mut self,
f: impl Fn(MonitorEventData) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static,
)
pub fn add_active_monitor_changed_handler( &mut self, f: impl Fn(MonitorEventData) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static, )
This method adds an event which executes when the active monitor is changed
use hyprland::event_listener::EventListener;
let mut listener = EventListener::new();
listener.add_active_monitor_changed_handler(|data| println!("Active monitor changed to: {data:#?}"));
listener.start_listener();
§impl AsyncEventListener
impl AsyncEventListener
pub fn add_active_window_changed_handler(
&mut self,
f: impl Fn(Option<WindowEventData>) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static,
)
pub fn add_active_window_changed_handler( &mut self, f: impl Fn(Option<WindowEventData>) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static, )
This method adds an event which executes when the active window is changed
use hyprland::event_listener::EventListener;
let mut listener = EventListener::new();
listener.add_active_window_changed_handler(|data| println!("Active window changed: {data:#?}"));
listener.start_listener();
§impl AsyncEventListener
impl AsyncEventListener
pub fn add_fullscreen_state_changed_handler(
&mut self,
f: impl Fn(bool) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static,
)
pub fn add_fullscreen_state_changed_handler( &mut self, f: impl Fn(bool) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static, )
This method adds an event which executes when the fullscreen state is changed
use hyprland::event_listener::EventListener;
let mut listener = EventListener::new();
listener.add_fullscreen_state_changed_handler(|state| println!("Fullscreen is on: {state:#?}"));
listener.start_listener();
§impl AsyncEventListener
impl AsyncEventListener
pub fn add_monitor_added_handler(
&mut self,
f: impl Fn(MonitorAddedEventData) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static,
)
pub fn add_monitor_added_handler( &mut self, f: impl Fn(MonitorAddedEventData) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static, )
This method adds an event which executes when a new monitor is added
use hyprland::event_listener::EventListener;
let mut listener = EventListener::new();
listener.add_monitor_added_handler(|data| println!("Monitor added: {data:#?}"));
listener.start_listener();
§impl AsyncEventListener
impl AsyncEventListener
pub fn add_monitor_removed_handler(
&mut self,
f: impl Fn(String) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static,
)
pub fn add_monitor_removed_handler( &mut self, f: impl Fn(String) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static, )
This method adds an event which executes when a monitor is removed
use hyprland::event_listener::EventListener;
let mut listener = EventListener::new();
listener.add_monitor_removed_handler(|data| println!("Monitor removed: {data:#?}"));
listener.start_listener();
§impl AsyncEventListener
impl AsyncEventListener
pub fn add_window_opened_handler(
&mut self,
f: impl Fn(WindowOpenEvent) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static,
)
pub fn add_window_opened_handler( &mut self, f: impl Fn(WindowOpenEvent) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static, )
This method adds an event which executes when a window is opened
use hyprland::event_listener::EventListener;
let mut listener = EventListener::new();
listener.add_window_opened_handler(|data| println!("Window opened: {data:#?}"));
listener.start_listener();
§impl AsyncEventListener
impl AsyncEventListener
pub fn add_window_closed_handler(
&mut self,
f: impl Fn(Address) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static,
)
pub fn add_window_closed_handler( &mut self, f: impl Fn(Address) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static, )
This method adds an event which executes when a window is closed
use hyprland::event_listener::EventListener;
let mut listener = EventListener::new();
listener.add_window_closed_handler(|data| println!("Window closed: {data:#?}"));
listener.start_listener();
§impl AsyncEventListener
impl AsyncEventListener
pub fn add_window_moved_handler(
&mut self,
f: impl Fn(WindowMoveEvent) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static,
)
pub fn add_window_moved_handler( &mut self, f: impl Fn(WindowMoveEvent) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static, )
This method adds an event which executes when a window is moved
use hyprland::event_listener::EventListener;
let mut listener = EventListener::new();
listener.add_window_moved_handler(|data| println!("Window moved: {data:#?}"));
listener.start_listener();
§impl AsyncEventListener
impl AsyncEventListener
pub fn add_special_removed_handler(
&mut self,
f: impl Fn(String) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static,
)
pub fn add_special_removed_handler( &mut self, f: impl Fn(String) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static, )
This method adds an event which executes when a monitor’s special workspace is removed
use hyprland::event_listener::EventListener;
let mut listener = EventListener::new();
listener.add_special_removed_handler(|monitor| println!("Special Workspace removed: {monitor:#?}"));
listener.start_listener();
§impl AsyncEventListener
impl AsyncEventListener
pub fn add_changed_special_handler(
&mut self,
f: impl Fn(ChangedSpecialEventData) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static,
)
pub fn add_changed_special_handler( &mut self, f: impl Fn(ChangedSpecialEventData) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static, )
This method adds an event which executes when a monitor’s special workspace is changed
use hyprland::event_listener::EventListener;
let mut listener = EventListener::new();
listener.add_changed_special_handler(|data| println!("Special Workspace changed: {data:#?}"));
listener.start_listener();
§impl AsyncEventListener
impl AsyncEventListener
pub fn add_layout_changed_handler(
&mut self,
f: impl Fn(LayoutEvent) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static,
)
pub fn add_layout_changed_handler( &mut self, f: impl Fn(LayoutEvent) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static, )
This method adds an event which executes when the keyboard layout is changed
use hyprland::event_listener::EventListener;
let mut listener = EventListener::new();
listener.add_layout_changed_handler(|data| println!("Layout changed: {data:#?}"));
listener.start_listener();
§impl AsyncEventListener
impl AsyncEventListener
pub fn add_sub_map_changed_handler(
&mut self,
f: impl Fn(String) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static,
)
pub fn add_sub_map_changed_handler( &mut self, f: impl Fn(String) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static, )
This method adds an event which executes when the submap is changed
use hyprland::event_listener::EventListener;
let mut listener = EventListener::new();
listener.add_sub_map_changed_handler(|data| println!("Submap changed: {data:#?}"));
listener.start_listener();
§impl AsyncEventListener
impl AsyncEventListener
pub fn add_layer_opened_handler(
&mut self,
f: impl Fn(String) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static,
)
pub fn add_layer_opened_handler( &mut self, f: impl Fn(String) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static, )
This method adds an event which executes when a new layer is opened
use hyprland::event_listener::EventListener;
let mut listener = EventListener::new();
listener.add_layer_opened_handler(|data| println!("Layer opened: {data:#?}"));
listener.start_listener();
§impl AsyncEventListener
impl AsyncEventListener
pub fn add_layer_closed_handler(
&mut self,
f: impl Fn(String) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static,
)
pub fn add_layer_closed_handler( &mut self, f: impl Fn(String) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static, )
This method adds an event which executes when a layer is closed
use hyprland::event_listener::EventListener;
let mut listener = EventListener::new();
listener.add_layer_closed_handler(|data| println!("Layer closed: {data:#?}"));
listener.start_listener();
§impl AsyncEventListener
impl AsyncEventListener
pub fn add_float_state_changed_handler(
&mut self,
f: impl Fn(WindowFloatEventData) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static,
)
pub fn add_float_state_changed_handler( &mut self, f: impl Fn(WindowFloatEventData) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static, )
This method adds an event which executes when the float state of a window is changed
use hyprland::event_listener::EventListener;
let mut listener = EventListener::new();
listener.add_float_state_changed_handler(|data| println!("Float state changed: {data:#?}"));
listener.start_listener();
§impl AsyncEventListener
impl AsyncEventListener
pub fn add_urgent_state_changed_handler(
&mut self,
f: impl Fn(Address) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static,
)
pub fn add_urgent_state_changed_handler( &mut self, f: impl Fn(Address) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static, )
This method adds an event which executes when the urgent state of a window is changed
use hyprland::event_listener::EventListener;
let mut listener = EventListener::new();
listener.add_urgent_state_changed_handler(|data| println!("urgent state changed: {data:#?}"));
listener.start_listener();
§impl AsyncEventListener
impl AsyncEventListener
pub fn add_window_title_changed_handler(
&mut self,
f: impl Fn(WindowTitleEventData) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static,
)
pub fn add_window_title_changed_handler( &mut self, f: impl Fn(WindowTitleEventData) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static, )
This method adds an event which executes when a window title is changed
use hyprland::event_listener::EventListener;
let mut listener = EventListener::new();
listener.add_window_title_changed_handler(|data| println!("A window title changed: {data:#?}"));
listener.start_listener();
§impl AsyncEventListener
impl AsyncEventListener
pub fn add_screencast_handler(
&mut self,
f: impl Fn(ScreencastEventData) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static,
)
pub fn add_screencast_handler( &mut self, f: impl Fn(ScreencastEventData) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static, )
This method adds an event which executes when the screencast state of a window is changed
use hyprland::event_listener::EventListener;
let mut listener = EventListener::new();
listener.add_screencast_handler(|data| println!("screencast state changed: {data:#?}"));
listener.start_listener();
§impl AsyncEventListener
impl AsyncEventListener
pub fn add_config_reloaded_handler(
&mut self,
f: impl Fn() -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static,
)
pub fn add_config_reloaded_handler( &mut self, f: impl Fn() -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static, )
This method adds an event which executes when the configuration of Hyprland is reloaded
use hyprland::event_listener::EventListener;
let mut listener = EventListener::new();
listener.add_config_reloaded_handler(|_empty| println!("config reloaded: {_empty:#?}"));
listener.start_listener();
§impl AsyncEventListener
impl AsyncEventListener
pub fn add_ignore_group_lock_state_changed_handler(
&mut self,
f: impl Fn(bool) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static,
)
pub fn add_ignore_group_lock_state_changed_handler( &mut self, f: impl Fn(bool) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static, )
This method adds an event which executes when the state of ignore group lock is toggled
use hyprland::event_listener::EventListener;
let mut listener = EventListener::new();
listener.add_ignore_group_lock_state_changed_handler(|data| println!("ignore group lock toggled to: {data:#?}"));
listener.start_listener();
§impl AsyncEventListener
impl AsyncEventListener
pub fn add_lock_groups_state_changed_handler(
&mut self,
f: impl Fn(bool) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static,
)
pub fn add_lock_groups_state_changed_handler( &mut self, f: impl Fn(bool) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static, )
This method adds an event which executes when the state of lock groups is toggled
use hyprland::event_listener::EventListener;
let mut listener = EventListener::new();
listener.add_lock_groups_state_changed_handler(|data| println!("lock group state toggled to: {data:#?}"));
listener.start_listener();
§impl AsyncEventListener
impl AsyncEventListener
pub fn add_window_pinned_handler(
&mut self,
f: impl Fn(WindowPinEventData) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static,
)
pub fn add_window_pinned_handler( &mut self, f: impl Fn(WindowPinEventData) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static, )
This method adds an event which executes when the pinned state of a window is changed
use hyprland::event_listener::EventListener;
let mut listener = EventListener::new();
listener.add_window_pinned_handler(|state| println!("window pin was set to: {state:#?}"));
listener.start_listener();
§impl AsyncEventListener
impl AsyncEventListener
pub fn add_group_toggled_handler(
&mut self,
f: impl Fn(GroupToggledEventData) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static,
)
pub fn add_group_toggled_handler( &mut self, f: impl Fn(GroupToggledEventData) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static, )
This method adds an event which executes when a group was toggled
use hyprland::event_listener::EventListener;
let mut listener = EventListener::new();
listener.add_group_toggled_handler(|data| println!("the group toggle state was set to: {data:#?}"));
listener.start_listener();
§impl AsyncEventListener
impl AsyncEventListener
pub fn add_window_moved_into_group_handler(
&mut self,
f: impl Fn(Address) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static,
)
pub fn add_window_moved_into_group_handler( &mut self, f: impl Fn(Address) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static, )
This method adds an event which executes when a window was moved into a group
use hyprland::event_listener::EventListener;
let mut listener = EventListener::new();
listener.add_window_moved_into_group_handler(|addr| println!("a window was moved into a group with the address of: {addr:#?}"));
listener.start_listener();
§impl AsyncEventListener
impl AsyncEventListener
pub fn add_window_moved_out_of_group_handler(
&mut self,
f: impl Fn(Address) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static,
)
pub fn add_window_moved_out_of_group_handler( &mut self, f: impl Fn(Address) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static, )
This method adds an event which executes when a window was moved out of a group
use hyprland::event_listener::EventListener;
let mut listener = EventListener::new();
listener.add_window_moved_out_of_group_handler(|addr| println!("a window was moved out of a group with the address of: {addr:#?}"));
listener.start_listener();
§impl AsyncEventListener
impl AsyncEventListener
pub fn add_unknown_handler(
&mut self,
f: impl Fn(UnknownEventData) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static,
)
pub fn add_unknown_handler( &mut self, f: impl Fn(UnknownEventData) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync + 'static, )
This method adds an event which executes when the state of some unknown event changed
use hyprland::event_listener::EventListener;
let mut listener = EventListener::new();
listener.add_unknown_handler(|value| println!("unknown state changed to: {value:#?}"));
listener.start_listener();
Trait Implementations§
§impl Default for AsyncEventListener
impl Default for AsyncEventListener
§fn default() -> AsyncEventListener
fn default() -> AsyncEventListener
Auto Trait Implementations§
impl Freeze for AsyncEventListener
impl !RefUnwindSafe for AsyncEventListener
impl Send for AsyncEventListener
impl Sync for AsyncEventListener
impl Unpin for AsyncEventListener
impl !UnwindSafe for AsyncEventListener
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more