pub struct I3EventListener { /* private fields */ }
Expand description
Abstraction over an ipc socket to i3. Handles events.
Implementations§
Source§impl I3EventListener
impl I3EventListener
Sourcepub fn connect() -> Result<I3EventListener, EstablishError>
pub fn connect() -> Result<I3EventListener, EstablishError>
Establishes the IPC connection.
Examples found in repository?
examples/event_printer.rs (line 10)
9fn main() {
10 let mut listener = I3EventListener::connect().expect("failed to connect");
11 let subs = [
12 Subscription::Workspace,
13 Subscription::Output,
14 Subscription::Mode,
15 Subscription::Window,
16 Subscription::BarConfig,
17 Subscription::Binding,
18 ];
19 listener.subscribe(&subs).expect("failed to subscribe");
20 for event in listener.listen() {
21 println!("{:?}\n", event.expect("failed to get event"))
22 }
23}
More examples
examples/hovered_window.rs (line 10)
9fn main() {
10 let mut listener = I3EventListener::connect().expect("failed to connect");
11 listener
12 .subscribe(&[Subscription::Window])
13 .expect("failed to subscribe");
14 for event in listener.listen() {
15 match event {
16 Ok(Event::WindowEvent(w)) => {
17 println!("{}", w.container.name.unwrap_or("unnamed".to_owned()))
18 }
19 Err(e) => println!("Error: {}", e),
20 _ => unreachable!(),
21 }
22 }
23}
Sourcepub fn subscribe(
&mut self,
events: &[Subscription],
) -> Result<Subscribe, MessageError>
pub fn subscribe( &mut self, events: &[Subscription], ) -> Result<Subscribe, MessageError>
Subscribes your connection to certain events.
Examples found in repository?
examples/event_printer.rs (line 19)
9fn main() {
10 let mut listener = I3EventListener::connect().expect("failed to connect");
11 let subs = [
12 Subscription::Workspace,
13 Subscription::Output,
14 Subscription::Mode,
15 Subscription::Window,
16 Subscription::BarConfig,
17 Subscription::Binding,
18 ];
19 listener.subscribe(&subs).expect("failed to subscribe");
20 for event in listener.listen() {
21 println!("{:?}\n", event.expect("failed to get event"))
22 }
23}
More examples
examples/hovered_window.rs (line 12)
9fn main() {
10 let mut listener = I3EventListener::connect().expect("failed to connect");
11 listener
12 .subscribe(&[Subscription::Window])
13 .expect("failed to subscribe");
14 for event in listener.listen() {
15 match event {
16 Ok(Event::WindowEvent(w)) => {
17 println!("{}", w.container.name.unwrap_or("unnamed".to_owned()))
18 }
19 Err(e) => println!("Error: {}", e),
20 _ => unreachable!(),
21 }
22 }
23}
Sourcepub fn listen(&mut self) -> EventIterator<'_> ⓘ
pub fn listen(&mut self) -> EventIterator<'_> ⓘ
Iterate over subscribed events forever.
Examples found in repository?
examples/event_printer.rs (line 20)
9fn main() {
10 let mut listener = I3EventListener::connect().expect("failed to connect");
11 let subs = [
12 Subscription::Workspace,
13 Subscription::Output,
14 Subscription::Mode,
15 Subscription::Window,
16 Subscription::BarConfig,
17 Subscription::Binding,
18 ];
19 listener.subscribe(&subs).expect("failed to subscribe");
20 for event in listener.listen() {
21 println!("{:?}\n", event.expect("failed to get event"))
22 }
23}
More examples
examples/hovered_window.rs (line 14)
9fn main() {
10 let mut listener = I3EventListener::connect().expect("failed to connect");
11 listener
12 .subscribe(&[Subscription::Window])
13 .expect("failed to subscribe");
14 for event in listener.listen() {
15 match event {
16 Ok(Event::WindowEvent(w)) => {
17 println!("{}", w.container.name.unwrap_or("unnamed".to_owned()))
18 }
19 Err(e) => println!("Error: {}", e),
20 _ => unreachable!(),
21 }
22 }
23}
Trait Implementations§
Auto Trait Implementations§
impl Freeze for I3EventListener
impl RefUnwindSafe for I3EventListener
impl Send for I3EventListener
impl Sync for I3EventListener
impl Unpin for I3EventListener
impl UnwindSafe for I3EventListener
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
Mutably borrows from an owned value. Read more