Skip to main content

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 tauri::{Builder, generate_context};
8use tauri_plugin_deskulpt_core::shortcuts::ShortcutsExt;
9use tauri_plugin_deskulpt_core::states::CanvasImodeStateExt;
10use tauri_plugin_deskulpt_core::tray::TrayExt;
11use tauri_plugin_deskulpt_core::window::WindowExt;
12use tauri_plugin_deskulpt_widgets::WidgetsExt;
13
14/// Entry point for the Deskulpt backend.
15pub fn run() {
16    Builder::default()
17        .setup(move |app| {
18            // Hide the application from the dock on macOS because skipping
19            // taskbar is not applicable for macOS
20            #[cfg(target_os = "macos")]
21            app.set_activation_policy(tauri::ActivationPolicy::Accessory);
22
23            app.init_shortcuts();
24            app.create_canvas()?;
25            app.create_tray()?;
26
27            app.manage_canvas_imode()?;
28
29            app.widgets().maybe_add_starter()?;
30
31            Ok(())
32        })
33        .plugin(tauri_plugin_clipboard_manager::init())
34        .plugin(tauri_plugin_global_shortcut::Builder::new().build())
35        // Prevent the opener plugin from registering handler for click event
36        // so we can register our own that opens non-_blank anchors in new tab
37        .plugin(
38            tauri_plugin_opener::Builder::new()
39                .open_js_links_on_click(false)
40                .build(),
41        )
42        .plugin(tauri_plugin_deskulpt_core::init())
43        .plugin(tauri_plugin_deskulpt_settings::init())
44        .plugin(tauri_plugin_deskulpt_widgets::init())
45        .plugin(tauri_plugin_deskulpt_logs::init())
46        .run(generate_context!())
47        .expect("Error running the Deskulpt application");
48}