diff --git a/src/main.rs b/src/main.rs
index 1d39759..eae51c3 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -16,7 +16,7 @@ use std::{
};
use sm_session_notifier::SMSessionNotifier;
-use window_change::{win_event_hook_loop, WIN_CHANGE_CALLBACK};
+use window_change::{await_win_change_events};
use windows::{
core::Interface,
Win32::{
@@ -131,9 +131,7 @@ fn main() {
.boot_devices()
.expect("failed to get initial audio devices and sessions");
- *WIN_CHANGE_CALLBACK.lock().unwrap() = Some(Box::new(move |s| {
+ await_win_change_events(Box::new(move |s| {
muter.lock().unwrap().notify_window_changed(&s)
}));
-
- win_event_hook_loop();
}
diff --git a/src/window_change.rs b/src/window_change.rs
index b6914b0..0108f5c 100644
--- a/src/window_change.rs
+++ b/src/window_change.rs
@@ -14,7 +14,7 @@ use windows::Win32::{
use crate::pid_to_exe::pid_to_exe_path;
-pub static WIN_CHANGE_CALLBACK: Mutex