#![cfg_attr(all(windows, not(debug_assertions)), windows_subsystem = "windows")]
use anyhow::Result;
use bezel::{gpui::App, gpui_platform};
use gui::{
agent, boot,
model::{media, migrate, notify, settings, state, update, welcome},
view::{hotkey, menubar, root},
};
const BUNDLE_ID: &str = "sh.cydonia";
fn main() -> Result<()> {
agent::path::adopt();
migrate::run();
let settings = settings::load()?;
let mut state = state::restore();
welcome::seed(&mut state);
let app = gpui_platform::application();
app.on_reopen(|cx| {
if cx
.windows()
.iter()
.any(|window| window.downcast::<root::Cydonia>().is_some())
{
return;
}
let Ok(settings) = settings::load() else {
return;
};
let _ = root::open(settings, state::restore(), cx);
});
app.run(move |cx: &mut App| {
cx.set_app_identity(BUNDLE_ID, "Cydonia");
notify::on_response(cx);
boot::init(&settings, cx);
hotkey::apply(settings.shortcuts.activate(), cx);
media::init(cx);
update::init(settings.auto_update, cx);
menubar::init(cx);
root::open(settings, state, cx).expect("failed to open window");
cx.activate(true);
});
Ok(())
}