1pub mod file_lock;
2pub mod objects;
3pub mod style;
4pub mod theme_config;
5pub mod ui;
6
7use clap::{ArgAction, Parser};
8use gtk::prelude::*;
9use gtk::Application;
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()
37 .application_id("org.netrs.ui")
38 .build();
39
40 let _lock = match acquire_app_lock() {
41 Ok(lock) => lock,
42 Err(e) => {
43 eprintln!("Failed to start: {e}");
44 std::process::exit(1);
45 }
46 };
47
48 app.connect_activate(|app| {
49 load_css();
50 build_ui(app);
51 });
52
53 app.run();
54 Ok(())
55}