Hey, I'm integrating this library into ironbar for https://github.com/JakeStanger/ironbar/issues/18 and I've hit a bug:
When creating and switching to a new workspace, the event listener receives the added event and the change event. It appears when you then open a program (in this case kitty
) it panics.
This can be reproduced simply by starting the program, using hyperctl dispatch workspace 4
(or the number of any workspace that does not currently exist), and then opening a window in the new workspace.
Minimal code to reproduce:
let mut event_listener = EventListener::new();
event_listener.add_workspace_added_handler(|id| println!("workspace added: {id:?}"));
event_listener.add_workspace_destroy_handler(|id| println!("workspace removed: {id:?}"));
event_listener.add_workspace_change_handler(|id| println!("workspace changed to {id:?}"));
event_listener.start_listener().await.unwrap();
Stdout and the relevant part of the backtrace:
workspace changed to Regular(2)
workspace changed to Regular(1)
workspace changed to Regular(3)
workspace changed to Regular(1)
workspace changed to Regular(3)
workspace added: Regular(4)
workspace changed to Regular(4)
The application panicked (crashed).
Message: something has went down -[]-
Location: /home/jake/.cargo/registry/src/github.com-1ecc6299db9ec823/hyprland-0.2.4/src/event_listener/shared.rs:228
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BACKTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⋮ 7 frames hidden ⋮
8: hyprland::event_listener::shared::event_parser::h59e666c08b605020
at /home/jake/.cargo/registry/src/github.com-1ecc6299db9ec823/hyprland-0.2.4/src/event_listener/shared.rs:228
9: hyprland::event_listener::immutable::EventListener::start_listener::{{closure}}::h8810f2076f1a9397
at /home/jake/.cargo/registry/src/github.com-1ecc6299db9ec823/hyprland-0.2.4/src/event_listener/immutable.rs:260
10: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h1c521f9b23072b06
at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/future/mod.rs:91
11: ironbar::clients::hyprland::HyprlandEventClient::new::{{closure}}::h70a2c01650c455c5
at /home/jake/Programming/ironbar/src/clients/hyprland.rs:25
12: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::hdb2b9da00f74bf77
The line that's crashing is here:
https://github.com/yavko/hyprland-rs/blob/0f1b676924d9a614278f2a7e3bf4284369de64e1/src/event_listener/shared.rs#L228
It looks like perhaps there's another event being received after those two that is unsupported?
Hyprland version: hyprland-git r1728.7a775c0-1
Library version: 0.2.4
As an aside, it'd probably be better to return an Err
rather than panic in the library, so binaries can control how to handle the error.
bug