1pub mod file_lock;
2pub mod objects;
3pub mod style;
4pub mod theme_config;
5pub mod ui;
6
7use clap::{ArgAction, Parser};
8use gtk::Application;
9use gtk::prelude::*;
10
11use crate::file_lock::acquire_app_lock;
12use crate::style::load_css;
13use crate::ui::build_ui;
14
15#[derive(Parser, Debug)]
16#[command(name = "nmrs")]
17#[command(disable_version_flag = true)]
18#[command(version)]
19struct Args {
20 #[arg(short = 'V', long = "version", action = ArgAction::SetTrue)]
21 version: bool,
22}
23
24pub fn run() -> anyhow::Result<()> {
25 let args = Args::parse();
26
27 if let Args { version: true } = args {
28 println!(
29 "nmrs {}-beta ({})",
30 env!("CARGO_PKG_VERSION"),
31 env!("GIT_HASH")
32 );
33 return Ok(());
34 }
35
36 let app = Application::builder().application_id("org.nmrs.ui").build();
37
38 let _lock = match acquire_app_lock() {
39 Ok(lock) => lock,
40 Err(e) => {
41 eprintln!("Failed to start: {e}");
42 std::process::exit(1);
43 }
44 };
45
46 app.connect_activate(|app| {
47 load_css();
48 build_ui(app);
49 });
50
51 app.run();
52 Ok(())
53}