diff --git a/src/application.rs b/src/application.rs index f8fa5e0..b4c7f32 100644 --- a/src/application.rs +++ b/src/application.rs @@ -25,7 +25,6 @@ mod imp { window.present(); glib::spawn_future_local(async move { - // run this in glib's main loop let conn = zbus::connection::Builder::session() .expect("could not connect to the session bus") .internal_executor(false) @@ -33,6 +32,17 @@ mod imp { .await .expect("could not build connection to the session bus"); + // run this in glib's main loop + glib::spawn_future_local(glib::clone!( + #[strong] + conn, + async move { + loop { + conn.executor().tick().await; + } + } + )); + crate::Mpris::setup(conn.object_server(), &window) .await .expect("could not serve mpris"); @@ -49,10 +59,6 @@ mod imp { conn.request_name("org.mpris.MediaPlayer2.audrey") .await .expect("could not register name in session bus"); - - loop { - conn.executor().tick().await; - } }); } Some(win) => win.present(),