slint::include_modules!(); mod app; mod config; mod devscript; mod inhibit; mod input; mod palette; mod player; mod prompts; mod saved_queue; mod subsonic; use std::time::Duration; fn main() -> anyhow::Result<()> { env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("remus=info")).init(); let dev_script = std::env::var("REMUS_DEV_SCRIPT").ok(); let windowed = std::env::args().any(|a| a == "--windowed") || std::env::var_os("REMUS_WINDOWED").is_some(); let rt = tokio::runtime::Builder::new_multi_thread() .worker_threads(2) .enable_all() .build()?; let ui = AppWindow::new()?; ui.set_version(env!("CARGO_PKG_VERSION").into()); app::install(&ui, rt.handle().clone()); input::spawn_gamepad(|ev| { let _ = slint::invoke_from_event_loop(move || { app::with_app(move |app| match ev { input::PadEvent::Action(action, family) => app.pad_action(action, family), input::PadEvent::Present(family) => app.pad_present(family), }) }); }); // Kept alive until the event loop ends. let fullscreen_retry = slint::Timer::default(); if !windowed { ui.window().set_fullscreen(true); // Compositors ignore the request until the window is mapped, and a // tiling one (COSMIC) can take the window back right after granting // it. Keep asking until fullscreen has held for a second, giving up // after five. Then stop, so a later F11 to leave fullscreen sticks. let weak = ui.as_weak(); let (mut ticks, mut held) = (0, 0); fullscreen_retry.start(slint::TimerMode::Repeated, Duration::from_millis(100), move || { let Some(ui) = weak.upgrade() else { return }; if ticks >= 50 || held >= 10 { return; } ticks += 1; if ui.window().is_fullscreen() { held += 1; return; } held = 0; log::debug!("not fullscreen yet ({:?}), asking again", ui.window().size()); ui.window().set_fullscreen(false); ui.window().set_fullscreen(true); }); } if let Some(script) = dev_script { devscript::run(&ui, &script); } ui.run()?; app::shutdown(); drop(rt); Ok(()) }