deskulpt/
lib.rs

1#![doc = include_str!("../README.md")]
2#![doc(
3    html_logo_url = "https://github.com/deskulpt-apps/Deskulpt/raw/main/public/deskulpt.svg",
4    html_favicon_url = "https://github.com/deskulpt-apps/Deskulpt/raw/main/public/deskulpt.svg"
5)]
6
7use deskulpt_core::path::PathExt;
8use deskulpt_core::shortcuts::ShortcutsExt;
9use deskulpt_core::states::{CanvasImodeStateExt, LoggingStateExt};
10use deskulpt_core::tray::TrayExt;
11use deskulpt_core::window::WindowExt;
12use deskulpt_widgets::WidgetsExt;
13use tauri::{Builder, generate_context};
14
15/// Entry point for the Deskulpt backend.
16pub fn run() {
17    Builder::default()
18        .setup(move |app| {
19            app.init_widgets_dir()?;
20            app.init_persist_dir()?;
21            app.init_logs_dir()?;
22
23            app.manage_logging()?;
24
25            // Hide the application from the dock on macOS because skipping
26            // taskbar is not applicable for macOS
27            #[cfg(target_os = "macos")]
28            app.set_activation_policy(tauri::ActivationPolicy::Accessory);
29
30            app.init_shortcuts();
31            app.create_manager()?;
32            app.create_canvas()?;
33            app.create_tray()?;
34
35            app.manage_canvas_imode()?;
36
37            app.widgets().maybe_add_starter()?;
38
39            Ok(())
40        })
41        .on_window_event(deskulpt_core::window::on_window_event)
42        .plugin(tauri_plugin_clipboard_manager::init())
43        .plugin(tauri_plugin_global_shortcut::Builder::new().build())
44        // Prevent the opener plugin from registering handler for click event
45        // so we can register our own that opens non-_blank anchors in new tab
46        .plugin(
47            tauri_plugin_opener::Builder::new()
48                .open_js_links_on_click(false)
49                .build(),
50        )
51        .plugin(deskulpt_core::init())
52        .plugin(deskulpt_settings::init())
53        .plugin(deskulpt_widgets::init())
54        .run(generate_context!())
55        .expect("Error running the Deskulpt application");
56}